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

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.
The following is the error log.
How can I fix the error?

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.

Related

502 Bad Gateway nginx/1.10.3 (Ubuntu) - Angular app down

I have an website in Angular hosted on AWS. On my local machine, the app works with npm start. However, when I ssh and update the changes I get an 502 Bad Request Error. It looks like this might be a dependency issue. Do you know know to troubleshoot this?

403 Squid error after successful deployment on elastic beanstalk

I'm stuck with the launching of my node.js server and client (nuxt) environments. After successful deployment, both of them started normally (saw that in logs), but I can't access them using a browser because of a 403 squid error.
How could this issue be sold?
A VPN service was activated in a browser, and this is why squid blocked me.

The Nginx server returns error 502 for some directories (Express Application)

I'm running an express application using nginx web server on Ubuntu. everything works fine but today when I added two more directories using app.get method and re-deploy my app, the new directories won't work and it returns 502 Bad Gateway errors (old directoriesn are working fine). Restarting pm2, nginx and the server itself didn't help. What should I do?
After a couple of hours I realized that the problem was in my code and not relevant to nginx. But because of pm2 the server would not crash to help me find that out.
running normal run command:
node server.js
revealed the mistake

Heroku Deployment 404 Error with Node.js and Express.js Server

Anyone willing to help with a Heroku Deployment?
When I run my local repo the server works great but once I deploy it on Heroku I get a 404 Error.
I am using Node.js Express Server.
The server console is suppose to generate: Listening on port 5000!
The error I get instead is: {"error":{"message":"Error not found in app.js"}}
Git Hub Repo
https://github.com/instant-help/instant-help-backend
Deployed Repo
https://thawing-river-10076.herokuapp.com/

502 Gateway Error on AWS - API

I am creating a test web app and have deployed it to AWS Ubuntu server using nginx..
I am getting a 502 Bad Gateway error when it tries to reach my API..
I am new to this and have started node.js and all seems to working fine except when I want to perform an API call to mongodb to read or write information. it is working fine locally so I am at a loss....
GET http://ec2-54-72-145-112.eu-west-1.compute.amazonaws.com/api/rest/golf 502 (Bad Gateway)
this is nginx server config
location /xxxxxxxxxxxxxxx{
alias /home/ubuntu/xxxxxxxxxxxxxx/site/public;
}
location /api/ {
proxy_pass http://127.0.x.1:8180/api/;
}
..
I know I may not be giving enough info but hopefully someone has an idea..
Thanks!
The nginx error message HTTP 502 indicates the nginx is working fine but cannot reach your specified proxy. So I'd suggest you to check whether the port and binding IP are correct.
You can check which ports are bound by which application using this command on your Ubuntu machine:
netstat -tulpen
You should see a line with the column "Local Address" and in your case the value 127.0.x.1:8180. If it's not there try to figure out which port is bound by your node application and reconfigure the nginx to use that port.

Resources