Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plotly dash: change default port

Tags:

plotly-dash

Following plotly dash getting started guide but when trying to run python app.py get message:

OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Seems the default address: http://127.0.0.1:8050/ is already being used. How can the default port be changed so I can get this to work?

like image 768
Vlad Avatar asked Aug 22 '17 02:08

Vlad


3 Answers

As we can see in Dash.run_server method definition, port can be passed as parameter:

def run_server(self,
               port=8050,
               debug=True,
               threaded=True,
               **flask_run_options):
    self.server.run(port=port, debug=debug, **flask_run_options)

So, if you need to use another port:

if __name__ == '__main__':
    app.run_server(debug=True, port=8051) # or whatever you choose
like image 186
Oleh Rybalchenko Avatar answered Nov 06 '22 18:11

Oleh Rybalchenko


Note that in Julia, you can change the port by specifying the port number in the run_server arguments without specifying "port=". For example,

run_server(app, "0.0.0.0", 8000, debug = true)
like image 1
AaronJPung Avatar answered Nov 06 '22 17:11

AaronJPung


You can also set the environment variable PORT in your terminal before launching the Dash app:

https://github.com/plotly/dash/blob/c77912a3183adfccfd4ef84df91eca7fa9c7d543/dash/_configs.py#L34

like image 1
tash Avatar answered Nov 06 '22 17:11

tash