By Jeet Gandhi
I am trying to run a MERN stack application on an ubuntu server. I have used pm2 to run my server.js and I have used the npm build command to create the static assets in the build folder. Here is my /etc/nginx/sites-available/osnvision file :
server {
listen 80;
root /var/www/html/osnvision/client/build;
index index.html index.htm;
server_name 192.168.210.38;
location / {
proxy_pass http://192.168.210.38:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Here is my pm2 server-error log:
WARNING: NODE_APP_INSTANCE value of '1' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
{ Error: listen EADDRINUSE :::5000
at Server.setupListenHandle [as _listen2] (net.js:1346:14)
at listenInCluster (net.js:1387:12)
at Server.listen (net.js:1475:7)
at Function.listen (/var/www/html/osnvision/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/var/www/html/osnvision/server.js:45:5)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:27:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
errno: 'EADDRINUSE',
code: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 5000 }
My server.js runs on port 5000. I am getting all kinds of ngins errors like Bad Gateway(502), Cannot get/ (404) and sometimes only the first index.html runs but the other pages are not found. Please help me figure out my mistake. I am new to this. Any help would be appreciated. Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
I can see that you’ve set your proxy_pass to http://192.168.210.38:5000;. Is your application actually listening on that IP address?
What I could suggest is running netstat in order to find out the exact port:
sudo netstat -plant | grep 5000
If the node application is running on localhost you might have to adjust the proxy_pass to http://127.0.0.1:5000;.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.