Question
How can I get a response from a Nodejs app running with PM2?
I have a wordpress backend + nextjs server-side-rendering/react app set up on Ubuntu 18.04. I’m following this tutorial on correctly setting up nodejs apps: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04
My node app starts with this start script:
"start": "export NODE_ENV=production PORT=8000 && node server.js"
If I simply run npm run start, then I am able to get a response when I curl http://localhost:8000
However, if I go through PM2, and I run pm2 start npm – start, then PM2 shows the process as running but I no longer get a response when I run curl.
curl: (7) Failed to connect to localhost port 8000: Connection refused
Is this normal? how can I check the response?
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.
×
Go through this tutorial it might help- https://www.loginradius.com/engineering/blog/react-app-deployment/