diff --git a/IPython/parallel/util.py b/IPython/parallel/util.py index 352dc81..714a035 100644 --- a/IPython/parallel/util.py +++ b/IPython/parallel/util.py @@ -43,6 +43,7 @@ from IPython.external.decorator import decorator # IPython imports from IPython.config.application import Application +from IPython.utils.localinterfaces import LOCALHOST, PUBLIC_IPS from IPython.zmq.log import EnginePUBHandler from IPython.zmq.serialize import ( unserialize_object, serialize_object, pack_apply_message, unpack_apply_message @@ -186,14 +187,9 @@ def disambiguate_ip_address(ip, location=None): """turn multi-ip interfaces '0.0.0.0' and '*' into connectable ones, based on the location (default interpretation of location is localhost).""" if ip in ('0.0.0.0', '*'): - try: - external_ips = socket.gethostbyname_ex(socket.gethostname())[2] - except (socket.gaierror, IndexError): - # couldn't identify this machine, assume localhost - external_ips = [] - if location is None or location in external_ips or not external_ips: + if location is None or location in PUBLIC_IPS or not PUBLIC_IPS: # If location is unspecified or cannot be determined, assume local - ip='127.0.0.1' + ip = LOCALHOST elif location: return location return ip