Not able to deploy dash application on Gunicorn

Viewed 3073

I want to deploy a dash application on Gunicorn. But I am not able to do so. I see no errors appearing on the screen when I execute the gunicorn <module_name>:<variable_name>

Versions:

  • gunicorn (20.0.4)
  • dash (1.17.0)
  • dash-core-components (1.13.0)
  • dash-html-components (1.1.1)
  • dash-renderer (1.8.3)
  • dash-table (4.11.0)

my dash application, file name: analyzer.py

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import flask

<data_frame definitions>


app = dash.Dash()
server = app.server

<app.layout>

<Call backs>

## at the end

if __name__ == '__main__':
    app.run_server()

When I use the below command, I see no errors on the screen, but yet I can’t reach the application from the browser.

[user1@myHost]$ gunicorn analyzer:server -b:8000

[2021-04-16 16:57:58 +0200] [8334] [INFO] Starting gunicorn 20.0.4
[2021-04-16 16:57:58 +0200] [8334] [INFO] Listening at: http://0.0.0.0:8000 (8334)
[2021-04-16 16:57:58 +0200] [8334] [INFO] Using worker: sync
[2021-04-16 16:57:58 +0200] [8345] [INFO] Booting worker with pid: 8345

I see that the port is listening, however, I am not able to open my dashboard on the server’s public IP and 0.0.0.0 The port 8000 is in listen mode

sudo lsof -i -P -n | grep LISTEN

gunicorn  13003     user1    5u  IPv4 49878669      0t0  TCP *:8000 (LISTEN)
gunicorn  13015     user1    5u  IPv4 49878669      0t0  TCP *:8000 (LISTEN)

Could you please tell me where I am going wrong?

2 Answers

When a server is told to listen to 0.0.0.0, that means "listen on all bound IP addresses". Browsers can use any IP address that is bound to that server to access it. The 127 family of addresses is one of the sets of addresses that is guaranteed to be bound to every machine.

That means you should be able to browse to https://127.0.0.0:8000 to view the webapp. Also, https://127.0.0.1:8000, https://127.0.1.0:8000, https://127.666.312.432:8000, etc.

However, asking a web browser to visit https://0.0.0.0 means "I do not know where I want to connect to" and always fails. That includes all ports, so attempting to browse to https://0.0.0.0:8000 will always fail.

Since I was not facing any error messages on terminal, I tried wget and found a 200 OK response. This made it clear that I was not able to fetch my dashboard through the browser. So I added the port to firewalld and restarted firewalld. The dashboard was accessible through the browser.

Thank you people, for your time.

Related