Plotly-Dash app refuses to connect to 127.0.0.1:8050

This is the python test program (not using jupyter):

app = dash.Dash()
app.layout = html.Div(‘Dash Test’)
if name == ‘main’:
app.run_server(debug=True)

I’m trying this in VS Code in debug mode on Ubuntu 20.04, using python3

When I start this it says this in the terminal:

  • Serving Flask app “dashtest” (lazy loading)
  • Environment: development
  • Debug mode: on

When I try connecting to http://127.0.0.1:8050 the browser (Brave) says:
This site can’t be reached
127.0.0.1 refused to connect.
ERR_CONNECTION_REFUSED

tcpdump has this:

07:54:16.478171 IP localhost.52914 > localhost.8050: Flags [S], seq 3262221086, win 65495, options [mss 65495,sackOK,TS val 3886135585 ecr 0,nop,wscale 7], length 0
0x0000: 4500 003c e07c 4000 4006 5c3d 7f00 0001 E…<.|@.@.=…
0x0010: 7f00 0001 ceb2 1f72 c271 8b1e 0000 0000 …r.q…
0x0020: a002 ffd7 fe30 0000 0204 ffd7 0402 080a …0…
0x0030: e7a1 b921 0000 0000 0103 0307 …!..
07:54:16.478186 IP localhost.8050 > localhost.52914: Flags [R.], seq 0, ack 3262221087, win 0, length 0
0x0000: 4500 0028 0000 4000 4006 3cce 7f00 0001 E…(…@.@.<…
0x0010: 7f00 0001 1f72 ceb2 0000 0000 c271 8b1f …r…q…
0x0020: 5014 0000 7618 0000 P…v…

I’ve also tried this with debug=False and it makes no difference.

Plotly-only programs work fine.

thanks, Bob

Try:
if name == ‘main’:
app.run_server(debug=True, use_reloader=False)