502 Bad Gateway error

Hi i have set up discourse now (working) but i get the “502 Bad Gateway” error often, and the site is very slow? How to fix this problem in the best way?:s

Do you have a spinning disk or very little ram?


my Discourse is on VPS

here is the VPS data

CPU Cores 1
Total CPU Speed 2.4Ghz
Memory 1Gb
Disk Space 20Gb

I still get the 502 Bad Gateway error sometimes. :frowning: any ideas how to fix this issue?

Generic Unix server performance guides can help diagnose, but you may have too little RAM for the current load.

1 Like

Did you let discourse-setup create swap?

Do you have plugins installed?

no, that was the issue, my VPS provider didnt allow me to execute the command
“swapon /swapfile” but somehow i did install docker without it, and then i just “nano containers/app.yml” with all the data, and then ran “./launcher start app”… Yes i have some plugins installed also.

So discourse-setup warned you that you didn’t have enough ram and you were clever enough I bypass that warning. And the docs say that you need swap of you have less than two gb. Even with 2gb, without swap, you’ll likely have trouble when you rebuild to do an upgrade.

idk, 1 only have 1 GIG Ram on my VPS, (as i mentioned in the earlier post). so i need to fix the swap and the docker? Right

Any useful commands i can use then? (i be grateful for any help) thank you

reminds me this topic

So your vps might not have full virtualization, and it might be easier to change hosting provider, getting ahead of future problems.


Contact them and get that resolved.
However, many VPS providers just don’t want you to do that since it wears out their SSD drives too quickly.


ok 2nd option? i cannot change VPS provider and i cannot execute “swapon /swapfile”, is they no other way to fix the issue? :confused:

:roll_eyes: No, there is no other way to fix the issue. You need swap.

1 Like

Talk to the VPS provider about upgrading your RAM amount. You don’t need swap with enough RAM.
You could look at using a service monitoring utility like monit to automatically restart your container when processes crash but the problem will get worse the more active users you have and there’s a risk of corrupting the database over time.

ok thanks for the answer, then i know

If you want to do without swap completely then you’ll need at least 4GB of RAM otherwise your upgrades will miserably fail - which will probably mean you will need to spend 4x what you’re spending right now.