diff --git a/dash/dash.py b/dash/dash.py index ec243c43a0..d00a4bf2a5 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -2005,25 +2005,26 @@ def delete_resource(resources): # pylint: disable=protected-access delete_resource(self.css._resources._resources) + # pylint: disable=too-many-branches def run( self, - host="127.0.0.1", - port="8050", - proxy=None, - debug=None, + host: Optional[str] = None, + port: Optional[Union[str, int]] = None, + proxy: Optional[str] = None, + debug: Optional[bool] = None, jupyter_mode: Optional[JupyterDisplayMode] = None, - jupyter_width="100%", - jupyter_height=650, - jupyter_server_url=None, - dev_tools_ui=None, - dev_tools_props_check=None, - dev_tools_serve_dev_bundles=None, - dev_tools_hot_reload=None, - dev_tools_hot_reload_interval=None, - dev_tools_hot_reload_watch_interval=None, - dev_tools_hot_reload_max_retry=None, - dev_tools_silence_routes_logging=None, - dev_tools_prune_errors=None, + jupyter_width: str = "100%", + jupyter_height: int = 650, + jupyter_server_url: Optional[str] = None, + dev_tools_ui: Optional[bool] = None, + dev_tools_props_check: Optional[bool] = None, + dev_tools_serve_dev_bundles: Optional[bool] = None, + dev_tools_hot_reload: Optional[bool] = None, + dev_tools_hot_reload_interval: Optional[int] = None, + dev_tools_hot_reload_watch_interval: Optional[int] = None, + dev_tools_hot_reload_max_retry: Optional[int] = None, + dev_tools_silence_routes_logging: Optional[bool] = None, + dev_tools_prune_errors: Optional[bool] = None, **flask_run_options, ): """Start the flask server in local mode, you should not run this on a @@ -2032,11 +2033,11 @@ def run( If a parameter can be set by an environment variable, that is listed too. Values provided here take precedence over environment variables. - :param host: Host IP used to serve the application + :param host: Host IP used to serve the application, default to "127.0.0.1" env: ``HOST`` :type host: string - :param port: Port used to serve the application + :param port: Port used to serve the application, default to "8050" env: ``PORT`` :type port: int @@ -2137,8 +2138,14 @@ def run( # Evaluate the env variables at runtime - host = host or os.getenv("HOST") - port = port or os.getenv("PORT") + if "CONDA_PREFIX" in os.environ: + # Some conda systems has issue with setting the host environment + # to an invalid hostname. + # Related issue: https://github.com/plotly/dash/issues/3069 + host = host or "127.0.0.1" + else: + host = host or os.getenv("HOST", "127.0.0.1") + port = port or os.getenv("PORT", "8050") proxy = proxy or os.getenv("DASH_PROXY") # Verify port value