Visual Studio Dash Localhost Connection Refused

Hi all,

I recently got a new laptop to work a bit off the main computer that came with windows 10 home and I installed Visual Studios 2019 on it as it is the same version as my desktop. I’ve been trying to get the dash app to work on my laptop with no success.

The laptop is an HP Vivobook running an AMD 3200U with Windows 10 Home 64-bit.

Any code I try to run with a dash app on my local machine is not able to connect to the localhost. It just says that the site cannot be reached and that 127.0.0.1 refused to connect. The code that I was already working on from my desktop doesn’t work on the laptop. I tried the tutorial code on the Dash website here: Part 2. Layout | Dash for Python Documentation | Plotly. This code doesn’t work either on my laptop but does on my desktop. I’ve tried a few solutions I found but nothing has worked so far and I’ve kind of run out of solutions I can find to try.

For example, this is the code from the dash tutorial:

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(__name__)

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)

Hi,
I am trying dash for the first time and faced the same issue.
Have you found any work around yet?

Not a full fix but managed to get to at least be able to see the page by turning off debug mode. So the ode to run the app is now: app.run_server(). I can at least check how formatting changes look but I haven’t found why running debug mode breaks being able to connect to the localhost.

1 Like

Thanks for the reply. I did as you mentioned and it worked.

Hi

I just “upgraded” to the latest version of Visual Studio and had the same experience. The page only shows if debug is set to False.

I didn’t realize how great the Dev tools were until they stopped working. Can anyone suggest a solution?

Hi,

I face the same issue since I updated to Visual Studio 2019 Version 16.7.3.
When debug is True, page does not show up.

For me the Dash debug mode works, when starting the app in Visual Studio without debugging (CTRL + F5).
In my old VS version, normal start with debugging (F5) worked as well…

Following erros occur, when using normal start with debugging:

File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\pydevd.py", line 3149, in <module>
    main()
  File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\pydevd.py", line 3142, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\pydevd.py", line 2231, in run
    self.wait_for_ready_to_run()
  File "c:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\pydevd.py", line 649, in wait_for_ready_to_run
    self._py_db_command_thread_event.wait(0.1)
  File "C:\Python\Python37\lib\threading.py", line 552, in wait
    signaled = self._cond.wait(timeout)
  File "C:\Python\Python37\lib\threading.py", line 300, in wait
    gotit = waiter.acquire(True, timeout)