Site responds 502 Bad gateway - is it Ruby?

We have a Discourse that’s been running for at least three years and yesterday I made the mistake of restarting the instance in the hope it would take a domain change. The instance is running and we can see nginx is seeing requests form outside, but all visitors are getting “502 Bad gateway” all the time. Here’s an example entry in the nginx error log:

2020/06/22 19:03:26 [error] 11742#11742: *158 connect() failed (111: Connection refused) while connecting to upstream, client:, server: <my domain>, request: "GET                / HTTP/1.1", upstream: "", host: "<my domain>"

There’s no webserver running outside Docker so the app.yml file simply forwards 80 and 443 into the container. But what is supposed to be on port 3000? Is it suppose to be Ruby / Rails?

Hi Chris:

Yes, you are correct.

Rails runs on port 3000 in the Discourse app.

You might want to check the Rails log in the app to see if you can find out what is happening with Rails.

Hope this helps a little bit.

Were you trying to change the domain name for your instance?

There are procedures in place for that. if you don’t undertake the process, it can cause errors such as the one you’re experiencing.

Please follow this guide, it will help you change the domain name properly.
Change the domain name or rename my Discourse?


There is a “development” alternative to the live domain and somehow that has sneaked into the configuration such that everything but the images comes from the live domain but the images are coming from the dev domain. As the latter doesn’t have a certificate, we (quite rightly) run into the cross-site security issue and the images don’t load.

We are currently trying to rebuild the container, as suggested elsewhere.

An additional complication is that all traffic is going through CloudFlare so we’re now having problems with SSL certificates. Note sure if templates/cloudflare.template.yml still works?

You’ll need to disable cloudflare to get let’s encrypt to be able I request a certificate

1 Like

All sorted now. Our best tech managed to make a new build and has even got LetsEncrypt to work!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.