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

February 15, 2017 2.4k views
Ubuntu Deployment

i deployed my project following this link :
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 ???

2 Answers

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

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!