This question already has an answer here:

I am experiencing 502 Bad Gateway errors after deploying a python flask application using dokku on digital ocean. I followed this tutorial to deploy my app on digital ocean using dokku.

2018/10/23 07:40:59 [error] 28652#28652: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xx, server: api.domain.com, request: "GET / HTTP/1.1", upstream: "", host: "api.domain.com"

Here is proof that the app is up and listening for requests:

2018-10-23T07:37:30.165794640Z app[web.1]: [2018-10-23 07:37:30 +0000] [9] [INFO] Listening at: (9)

My question is how configure proxy_pass in a python flask dokku application.

marked as duplicate by HBruijn, kasperd, Ward Oct 24 '18 at 4:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You send the request to upstream: "" and your server is listening on

If there is no translation layer in between, I would say there is your problem.

You have to listen on the same port (5000 or 8000. Choose one) and you can't listen on localhost/ if you want to access the application from the outside.

  • What do you mean by translation layer? Also I am using gunicorn to serve the application. Does that have to do with why it is listening on the localhost? – Deschant Kounou Oct 23 '18 at 16:27
  • With translation layer I meant something like nat, that changes the port to the outside. But I don't think you have that. Yes i think gunicron is the right place to set these things up. – Christopher Perrin Oct 24 '18 at 8:52
  • I solved the problem by changing the gunicorn configuration in my project Procfile from web: gunicorn app:app -b$PORT -w 3 to web: gunicorn app:app -b$PORT -w 3. Thanks for setting me on the right track! – Deschant Kounou Oct 25 '18 at 9:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.