Question
Trying to host a react and node application on ubuntu using Nginx. What is wrong with my nginx configuration file?
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.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×