diff --git a/distributed/deploy/local.py b/distributed/deploy/local.py index 69f5d8af35..b7f736e1ed 100644 --- a/distributed/deploy/local.py +++ b/distributed/deploy/local.py @@ -62,6 +62,9 @@ class LocalCluster(SpecCluster): 'localhost:8787' or '0.0.0.0:8787'. Defaults to ':8787'. Set to ``None`` to disable the dashboard. Use ':0' for a random port. + When specifying only a port like ':8787', the dashboard will bind to the given interface from the ``host`` parameter. + If ``host`` is empty, binding will occur on all interfaces '0.0.0.0'. + To avoid firewall issues when deploying locally, set ``host`` to 'localhost'. worker_dashboard_address: str Address on which to listen for the Bokeh worker diagnostics server like 'localhost:8787' or '0.0.0.0:8787'. Defaults to None which disables the dashboard. diff --git a/distributed/node.py b/distributed/node.py index d41a340985..56d0a1882c 100644 --- a/distributed/node.py +++ b/distributed/node.py @@ -143,9 +143,14 @@ def start_http_server( self.http_server = HTTPServer(self.http_application, ssl_options=ssl_options) http_addresses = clean_dashboard_address(dashboard_address or default_port) - for http_address in http_addresses: - if http_address["address"] is None: + # Handle default case for dashboard address + # In case dashboard_address is given, e.g. ":8787" + # the address is empty and it is intended to listen to all interfaces + if dashboard_address is not None and http_address["address"] == "": + http_address["address"] = "0.0.0.0" + + if http_address["address"] is None or http_address["address"] == "": address = self._start_address if isinstance(address, (list, tuple)): address = address[0] diff --git a/distributed/tests/test_scheduler.py b/distributed/tests/test_scheduler.py index cfb6fdefdb..dada3e3fc9 100644 --- a/distributed/tests/test_scheduler.py +++ b/distributed/tests/test_scheduler.py @@ -1969,7 +1969,7 @@ async def test_scheduler_file(): @pytest.mark.parametrize( "dashboard_address,expect", [ - (None, ("::", "0.0.0.0")), + (None, ("::", "0.0.0.0", "127.0.0.1")), ("127.0.0.1:0", ("127.0.0.1",)), ], ) diff --git a/distributed/tests/test_worker.py b/distributed/tests/test_worker.py index 8bfcd8347b..0a2fed3219 100644 --- a/distributed/tests/test_worker.py +++ b/distributed/tests/test_worker.py @@ -1115,7 +1115,7 @@ async def test_service_hosts_match_worker(s): async with Worker(s.address, host="tcp://127.0.0.1") as w: sock = first(w.http_server._sockets.values()) - assert sock.getsockname()[0] in ("::", "0.0.0.0") + assert sock.getsockname()[0] in ("::", "127.0.0.1") # See what happens with e.g. `dask worker --listen-address tcp://:8811` async with Worker(s.address, host="") as w: