502 Bad Gateway after Ghost upgrade

October 8, 2014 8.9k views

my blog [http://jitendravyas.com/](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 http://pastebin.com/UbQfZVe7

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


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

  • Great, it is exactly as you said. thumb up! thanks dude ^_-

  • I fixed this error by resizing my droplet from the 5$ one to the 10$ one. It looks like I didn’t have enough RAM to install all the node_modules and that’s why it wouldn’t work.

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
  • @ryanpq I’m getting the same issue as OP but this has not helped. Is there any update on a fix for this as it did not fix OP’s problem either?

  • @BlueHat: Do you see any errors in nginx’s error log?

    sudo tail /var/log/nginx/error.log
  • @BlueHat Could you open a new question providing the details of how you tried to upgrade and the the errors that you are seeing? I just successfully upgraded a DigitalOcean One-Click Ghost 0.5.6 installation to 0.5.7 using:

    cd /var/www/
    wget http://ghost.org/zip/ghost-latest.zip
    rm -rf ghost/core
    unzip -uo ghost-latest.zip -d ghost
    chown -R ghost:ghost ghost/*
    cd ghost
    npm install --production
    service ghost restart

    See Ghost’s official upgrade docs.

  • @abs @kamaln7 Sure, sorry for piggybacking this one. I thought if it was quick we may have one tied up topic. I’ll create another question topic with my details.

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

Have another answer? Share your knowledge.