diff --git a/colossalai/cli/launcher/hostinfo.py b/colossalai/cli/launcher/hostinfo.py index 2f0830c58..065cbc371 100644 --- a/colossalai/cli/launcher/hostinfo.py +++ b/colossalai/cli/launcher/hostinfo.py @@ -1,5 +1,5 @@ -from typing import List import socket +from typing import List class HostInfo: @@ -35,9 +35,14 @@ class HostInfo: if port is None: port = 22 # no port specified, lets just use the ssh port - hostname = socket.getfqdn(hostname) + + # socket.getfqdn("127.0.0.1") does not return localhost + # on some users' machines + # thus, we directly return True if hostname is locahost, 127.0.0.1 or 0.0.0.0 if hostname in ("localhost", "127.0.0.1", "0.0.0.0"): return True + + hostname = socket.getfqdn(hostname) localhost = socket.gethostname() localaddrs = socket.getaddrinfo(localhost, port) targetaddrs = socket.getaddrinfo(hostname, port)