Add catch socket.gaierror for _matches_machine_hostname (#91119)
Summary: Add catch `socket.gaierror` for _matches_machine_hostname
Test Plan: Unit tests again
Reviewed By: kurman
Differential Revision: D42152245
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91119
Approved by: https://github.com/kurman