diff --git a/tests/distributed/_test_push_ar_worker.py b/tests/distributed/_test_push_ar_worker.py index c92c7bf03bc..14bc6ba4f46 100644 --- a/tests/distributed/_test_push_ar_worker.py +++ b/tests/distributed/_test_push_ar_worker.py @@ -19,7 +19,7 @@ import torch.distributed as dist def find_free_port() -> int: """Find a free TCP port for distributed init.""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind(("", 0)) + s.bind(("localhost", 0)) return s.getsockname()[1] diff --git a/tests/distributed/test_push_all_reduce.py b/tests/distributed/test_push_all_reduce.py index 9689c5e1000..8d97e094652 100644 --- a/tests/distributed/test_push_all_reduce.py +++ b/tests/distributed/test_push_all_reduce.py @@ -51,7 +51,7 @@ def _find_free_port() -> int: import socket with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.bind(("", 0)) + s.bind(("localhost", 0)) return s.getsockname()[1]