Dokku on Ubuntu droplet 502 Bad Gateway

October 20, 2015 2.5k views
Dokku Docker Deployment Nginx Ubuntu

Hello everyone!

I have fresh install of Dokku on Ubuntu droplet. After droplet creation I followed this DO tutorial. After successful deploy of application on dokku when I visit the application url I get the 502 Bad Gateway response. I don't have any custom configuration.

# nginx -t 
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# dokku nginx:error-logs spring-boot-dokku-demo
2015/10/20 14:59:08 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:08 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:08 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:08 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:08 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:09 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:09 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:09 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:10 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:27 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:27 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:28 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 14:59:28 [error] 15631#0: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.25:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:42 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:43 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:44 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:44 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:44 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:44 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"
2015/10/20 15:03:45 [error] 23451#0: *104 connect() failed (111: Connection refused) while connecting to upstream, client: 193.77.216.177, server: spring-boot-dokku-demo.grega.xyz, request: "GET / HTTP/1.1", upstream: "http://172.17.0.37:5000/", host: "spring-boot-dokku-demo.grega.xyz"

4 Answers

I had the same problem. Let the app run on port 5000. I'm not sure why but that's what nginx is redirecting to. I was running on 8080 and getting your same 502 until I decided to give port 5000 a try (given the logs) and... boom! It works.

If you get segmentation error during build, check version of sigil:
sigil -v
and if you see an error there, you might want to download sigil from its official git repo from releases and place it in the /usr/bin folder.

https://github.com/dokku/dokku/issues/2034

@fabioruxo , where did you change the port in the droplet's config ?

You have to wait for a little time for the droplet to get initialized first, and then it'll open normally.

I had the same problem. So, I tried to ssh into the droplet and figured that the droplet isn't fully initialized yet.

Have another answer? Share your knowledge.