2

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: "http://172.17.0.3:5000/", 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: http://127.0.0.1:8000 (9)

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

Deschant Kounou
  • 21
  • 1
  • 1
  • 3

1 Answers1

2

You send the request to upstream: "http://172.17.0.3:5000/" and your server is listening on http://127.0.0.1:8000

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/127.0.0.1 if you want to access the application from the outside.

Christopher Perrin
  • 4,741
  • 17
  • 32
  • 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 08:52
  • I solved the problem by changing the gunicorn configuration in my project Procfile from `web: gunicorn app:app -b 127.0.0.1:$PORT -w 3` to `web: gunicorn app:app -b 0.0.0.0:$PORT -w 3`. Thanks for setting me on the right track! – Deschant Kounou Oct 25 '18 at 09:13