I am trying to run the example dash application but upon trying to run, the browser says it is refusing to connect. I have checked and Google Chrome has access through the firewall.
The example code is:
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children=''' Dash: A web application framework for Python.
'''),
dcc.Graph( id='example-graph', figure={ 'data': [ {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'}, {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'}, ], 'layout': { 'title': 'Dash Data Visualization' } }
)
])
if __name__ == '__main__': app.run_server(debug=True)Here is a picture of my browser:
Does anyone understand this?
37 Answers
First check if you are accessing the right port, the default one (usually) is 8050:
Also, check if there is another Dash code running, it might be occupying the port.
If it does not work, try determining the host as an argument in app.runserver(args), like this:
app.run_server(host='0.0.0.0', debug=True)You might also want to determine the port as an argument like this:
app.run_server(host='0.0.0.0', port=8050, debug=True) Change
app.run_server(debug=True)to
app.run_server(debug=False)and then try.
2I ran into a similar issue. I was running Jupyter Lab in a container on a remote server. I can't offer specific code because I don't know your configuration, but for me this involved forwarding from 127.0.0.1:8050 to port 8050 on the container.
Hopefully this can help someone in the future.
0I had the same problem, and discovered I forgot to launch the app by runningpython app.pybefore visiting my browser. (Assuming your file is named app.py). Once I did this, all was well.
shows how to do this
1I did this change:
if __name__ == '__main__': app.run_server(host='localhost',port=8005)And the code worked fine for me!
Was experiencing the same issue and setting "debug=False" definitely was not a solution as "debug=True" is a part of the tutorial to show the "hot-reloading" functionality (see ).
Looked a bit and from the site below I noticed "alitarraf" mentioning that python could get stuck on an old version:
After seeing that I killed "python.exe" in the details tab of task manager. This resolved the issue for me.
Edit: After a reboot it seems like the issue also is gone.
I had the same problem, I was launching the app in the console (in Rstudio IDE), try to use the terminal, with the good python interpreter python3 app.py
And changing the port could help if the default one is already taken.
if __name__ == '__main__': app.run_server(host='0.0.0.0', port=8007, debug=False)