Report this

What is the reason for this report?

Flask application with gunicorn in the app platform does not work

Posted on January 20, 2021

I have a flask application that I am trying to run in the app of platforms with a gunicorn.

wsgi.py

from app import create_app

app = create_app()


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

gconfig.py

from multiprocessing import cpu_count

bind = '0.0.0.0:8080'

workers = (2 * cpu_count()) + 1
worker_class = 'gevent'
worker_connections = 1000

timeout = 60

Run Command

gunicorn --worker-tmp-dir /dev/shm -c gconfig.py wsgi:app

After the build in the logs:

app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [1] [INFO] Starting gunicorn 20.0.4
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [1] [INFO] Using worker: gevent
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [11] [INFO] Booting worker with pid: 11
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [12] [INFO] Booting worker with pid: 12
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [13] [INFO] Booting worker with pid: 13
app-name | 2021-01-20 15:24:25 [2021-01-20 13:24:25 +0000] [14] [INFO] Booting worker with pid: 14
app-name | 2021-01-20 15:24:26 [2021-01-20 13:24:25 +0000] [15] [INFO] Booting worker with pid: 15
app-name | 2021-01-20 15:24:26 [2021-01-20 13:24:26 +0000] [16] [INFO] Booting worker with pid: 16
app-name | 2021-01-20 15:24:26 [2021-01-20 13:24:26 +0000] [17] [INFO] Booting worker with pid: 17
app-name | 2021-01-20 15:24:26 [2021-01-20 13:24:26 +0000] [18] [INFO] Booting worker with pid: 18
app-name | 2021-01-20 15:24:27 [2021-01-20 13:24:27 +0000] [19] [INFO] Booting worker with pid: 19
app-name | 2021-01-20 15:24:27 [2021-01-20 13:24:27 +0000] [20] [INFO] Booting worker with pid: 20
app-name | 2021-01-20 15:24:28 [2021-01-20 13:24:28 +0000] [21] [INFO] Booting worker with pid: 21
app-name | 2021-01-20 15:24:29 [2021-01-20 13:24:28 +0000] [22] [INFO] Booting worker with pid: 22
app-name | 2021-01-20 15:24:29 [2021-01-20 13:24:29 +0000] [23] [INFO] Booting worker with pid: 23
app-name | 2021-01-20 15:24:30 [2021-01-20 13:24:30 +0000] [24] [INFO] Booting worker with pid: 24
app-name | 2021-01-20 15:24:30 [2021-01-20 13:24:30 +0000] [25] [INFO] Booting worker with pid: 25
app-name | 2021-01-20 15:24:31 [2021-01-20 13:24:31 +0000] [26] [INFO] Booting worker with pid: 26
app-name | 2021-01-20 15:24:32 [2021-01-20 13:24:32 +0000] [27] [INFO] Booting worker with pid: 27

When I go to the url, then in the browser I just have the text:

no healthy upstream


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

That configuration looks reasonable. Without seeing the application, this advice is just speculation. The App Platform does health checks against the http port specified for the application at deployment. If the app is getting past those, and then you’re seeing “no healthy upstreams” the application may be crashing after boot. This could be caused by exceeding memory limits for the application, by an internal error in the application, or more rarely by an error in our system. I’d recommend trying a larger instance size, and if you’re still seeing trouble contact support. Our support team (with your permission) can examine your running application to see if there’s anything we can see from our end.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.