502 Bad Gateway after Ghost upgrade

Posted October 8, 2014 10.2k views

my blog [](http://) was working fine and today I decided to upgrade the Ghost to latest version and I followed the first solution given on this page

But I actually forget to stop the ghost before to run upgrade command. It upgraded but now my site is not working. and Digital Ocean support is unable to help me.

This is the log of /var/log/nginx/error.log

Output of some more command which Digital ocean support asked me to share

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.

Submit an Answer
3 answers

I get this error a lot. It’s almost always because of some half-installed-but-broken-from-previous-try npm dependency, and npm is too dumb to know it’s broken. And the ghost json doesn’t have “unsafe-perm” set so that is really the root issue…

Anyway, this is what I tend to do in the ghost directory:
rm -rf node_modules && npm cache clean
npm install –production –unsafe-perm
chown -R ghost:ghost *
service ghost restart

A 502 error will usually indicate that the nginx server is not able to reach the upstream ghost process. Restarting these services will usually clear this up unless there are other issues causing ghost not to start:

sudo service ghost restart
sudo service nginx restart

Had the same problem. It turns out that I forgot to run npm install --production after copying the files.