Unable to fix NGINX 502: Bad Gateway error on a Digital Ocean droplet - Ubuntu 20.04
Asked Answered
D

1

1

I have deployed my website to a Digital Ocean droplet (Ubuntu 20.04 server).

Everything was working fine. Today, I did some changes to the website in my local machine. So I pushed the changes to GitHub and then cloned the GitHub repo again to the server. Then, I installed the dependencies and restarted PM2.

Now, when I visit my site https://sundaray.io, I get the following error. enter image description here

The following is the error log. enter image description here

How can I fix the error?

Dorton answered 6/4, 2021 at 11:16 Comment(7)
looks like your node as not running properly with pm2 please check itMcfarland
502 gateway mean server and Nginx is getting your request but there is issue with upstream.Mcfarland
try running the node server with pm2 and check application getting crashed or other 500 error..Mcfarland
Same as last time. Please share sudo nginx -T output. From what I can see your configuration need some general cleanup.Adrian
I figured out the problem. I have to create a .env file. By the way, why can't I copy paste code from VS code to VIM? I tried ctrl+v and ctrl+shift+v, but doesn't work.Dorton
Everything ok now. The server is working fine.Dorton
Thanks Timo and Harsh for your prompt responses. You guys are the best.Dorton
M
0

Simple meaning is

No HTTP server response, your Node Http server is not answering requests.

502 gateway mean server and Nginx is getting your request but there is issue with upstream.

you can use the command to show the logs of pm2

pm2 show

the application might be crashing or internal server 500 error.

Mcfarland answered 6/4, 2021 at 11:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.