Question

i can't upload image to my Ubuntu server when i use PM2

i deployed my project following this link : https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04 everything is ok , when i start my app with : node server.js i can upload image to server but when i use pm2 : pm2 start server.js i cant upload image to server … i tried to see logs : pm2 doesn’t restart app when i post upload request any help please ???


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

im still learning but looks like i fixed it for now, make sure you update pm2

  • npm install pm2@next -g
  • pm2 update

and start pm2 watching files but ignoring the folder and files where you are uploading, so for me it was the “uploads” folder in the same directory that i dont want pm2 to watch

sudo pm2 start server.js --watch --ignore-watch=“./uploads”

restart pm2 inbetween changes sudo pm2 restart <id number>

this way when i update my app it will restart the app, but i dont want it restarting if i just upload a file for example. Looks like it’s working for me anyway. otherwise ill just use nodemon to serve my app i guess

i have the same problem, when i start with node or nodemon it uploads fine, but pm2 doesnt, its like it restarts before it can finish loading i get 502 bad gateway