502 Bad Gateway after Ghost restart

December 15, 2014 5k views

I've recently been playing around with Ghost as a possible blogging platform and attempted to install a theme I found. I put the files into the ghost/content/themes folder and extracted the zip (that all went just fine). I then went to restart ghost as is suggested on the guide I was following and I'm now getting a 502 error from nginx.


The only command I tried to restart with was sudo service ghost restart.

I then found and attempted to do the same but to nginx and it said it restarted just fine but I'm still getting a 502 error.

Here is a copy of my /var/log/nginx/error.log -

1 comment
4 Answers


By looking at your error.log it looks like you might have a looping problem and haven't configure your blog url. Open config.js in your root directory and enter your domain name instead of

I would also restart nginx and ghost after that.

  • Hi aguilar1181, thanks for your answer. But sadly I've already done that when I first set everything up. My production url is set to ''.

    Any other ideas would be much appreciated!

  • I think I might have a solution. Try this to restart ghost

    npm start --production

    People have complaint that using this code to restart it always give them that 502 error and more specifically the complaint was use on another forum and they said it was in a DO server

    sudo service ghost restart
  • @aguilar1181 That's exactly what the Upstart script should be doing when you run
    sudo service ghost restart

    description "Ghost: Just a blogging platform"
    start on (local-filesystems and net-device-up IFACE=eth0)
    stop on runlevel [!12345]
    # If the process quits unexpectedly trigger a respawn
    setuid ghost
    setgid ghost
    env NODE_ENV=production
    chdir /var/www/ghost
    exec /usr/local/bin/npm start --production
    pre-stop exec /usr/local/bin/npm stop --production

    Though running it directly might show us what's going on here. I'd also check the contents of /var/log/upstart/ghost.log


I am getting similar error after ghost restart and log file suggest:
verbose stack Error: ENOENT, open '/var/www/package.json'
this persist after cache clean.

I know it's an old thread and I apologize for reviving but this thread just helped me get my ghost app back up and running after restoring a failed upgrade attempt. I'd like to point out that you should "cd" to your ghost installation folder before running npm --start production.. like this:

cd /var/www/ghost

This is an example of the ghost installation folder, YMMV.

After CD'ing to it, run the following:

npm start --production
Have another answer? Share your knowledge.