Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dash app refusing to start: '127.0.0.1 refused to connect.'

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 = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

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:

enter image description here

Does anyone understand this?

like image 263
geds133 Avatar asked May 19 '20 12:05

geds133


2 Answers

First check if you are accessing the right port, the default one (usually) is 8050: http://localhost: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)
like image 179
kha Avatar answered Sep 23 '22 14:09

kha


Change

app.run_server(debug=True)

to

app.run_server(debug=False)

and then try.

like image 29
Aqeel Haider Avatar answered Sep 20 '22 14:09

Aqeel Haider