The Nginx server returns error 502 for some directories (Express Application) - node.js

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

Related

Nest JS server returning 404 response to all the routes after changing node JS version on my machine

I am running my Nest JS application on my local server's PORT 3000 and my node version is 16.5.0. My application has multiple routes and all were giving correct responses. There was a requirement where I had to downgrade the node version to 14.17.0. After this change, I started my server again and here the problem comes. All the routes started giving the response like POST /user 404 not found and GET /user/:id 404 not found.
I have reverted back to node version 16.5.0 and removed the node_modules and re-installed it again and restarted the server as well. But still, I am getting the same issue.
All the approaches I tried above failed to resolve the issue. The only way which resolved the issue is by restarting the system and running the server again.

How to find out why I get 500 error from Firebase on server but not on localhost

I try to run my first node application on my server from subdomain. It works perfectly on my PC but when I move it to the server, seems everything works, site loads with all js except Firebase.
I get the following errors in chrome:
/firebase/firestore net::ERR_ABORTED 500 (Internal Server Error)
/firebase/app net::ERR_ABORTED 500 (Internal Server Error)
The 2 lines of my my .js triggers the error:
import firebase from '/firebase/app';
import '/firebase/firestore';
Obviously it can mean millions different issues but I have no idea how to find any logs or anything what would tell me why this error triggered.
I tried to turn off/on https. I checked logs on server but found nothing just the same 500 error in access log. I tried but couldn't find any node specific log on the server. I tried to re-install firebase. After I tried to re-install node and everything and re-started from scratch.
I tried to copy the whole node_modules folder to the server from my PC but didn't help.
I would expect it to run just as on localhost or at least see some log about the error so I could fix it. The server is Linux VPS with plesk obsidian. The app is on a subdomain, the main domain has php website running.

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

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.

How to find what is causing a 502 Bad Gateway nginx Ubuntu

I'm trying to deploy my app which using nodejs and angular. Everything looks fine on
sudo pm2 logs.
I have also done
sudo nginx -t
Nginx is ok and successful.
However when I look at the error.logs from nginx directory, I have this.
I then when to this link here Nginx error "1024 worker_connections are not enough"
I changed it to 1500 worker connections and I'm still in the same spot. Is there another way around this? Please help, I have been trying to deploy this website for over a week. Thank you for your time.

Website on Ajenti V with Node.JS content always throw 404

I install AjentiV to manage my website. Now I have an webapp on NodeJS and want to use with AjentiV. I follow a simple tutorial Setting up a Node.js website with Ajenti V (Keystone example) .
I config the Content of website to Node.JS, provide the script and config port 8080. I use port 8080 for the Node app, there are no error but I try the webapp always throw 404 - Not found result, in both port 80 and 8080.
Has anyone met this problem before? How can I make it works?
Thank you in advance! :)
Sorry, my bad. There is no problem with AjentiV and Node.JS content. The problem itself is the our webapp always throw 404 due to my fault config.

Resources