BlueHat
By:
BlueHat

502 Bad Gateway after Ghost restart

December 15, 2014 9k 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.

See http://elliotblackburn.com/

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

I then found https://www.digitalocean.com/community/questions/502-bad-gateway-after-ghost-upgrade?comment=24356 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 - http://pastebin.com/TLNHP5VU

1 comment
5 Answers

Hi,

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 my-ghost-blog.com

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 'http://www.elliotblackburn.com'.

    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
    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.

[deleted]

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

Hello this is just to bring everyone's notice about this faceless company called digital ocean. Their tech support is so bad, nothing works at all, how can a company that deals with sensitive information for their clients keep loosing data without anyway of recovering it. This is not the first time, data files of over a year. I have been on data recovery issue for over three weeks now yet they can't even offer telephone support even via skype. It is so bad that i keep being directed to folders that doesn't even exist to locate data files.

Have another answer? Share your knowledge.