Fixing a 502 Bad Gateway error after a Ghost update
2 min read

Fixing a 502 Bad Gateway error after a Ghost update

Fixing a 502 Bad Gateway error after a Ghost update

Since the previous Ghost update process was not as painless as advertised, I delayed getting version 1.8.6 for quite some time. Only the need of renewing my LetsEncrypt SSL certificates, also requiring some small downtime for the sites, got me to finally get up to date.

The first update went flawlessly and the one for this blog seemed to be just as fine. You can access your blog at https://itsybitsybytes.com, Ghost proudly announced me, only to be welcome by a big and ugly 502 Bad Gateway error screen...

starting Ghost

I was not the only one who encountered a 502 Bad Gateway Error after a Ghost Upgrade but my case was different. There was no error during the start and restart of Ghost and the log was just as clean.

The next step was checking the official Ghost upgrade troubleshooting page but the instructions there were also completely useless...

Bad Gateway
If you browser shows 502 Bad Gateway, then your Ghost blog is not running.
Please navigate to your Ghost installation folder and run ghost ls to check wether your instance is running.
If it's stopped, please run ghost start. You can also run ghost log -f to watch the Ghost log.

My instance did ran and ghost start did nothing. It seemed to be another kind of problem.

The Ghost-CLI Github issues page did not contain any useful tips, just a plethora of different issues. Again I found myself without a solution.

The problem seemed to be a Node/npm related, since running the debugging command sudo ghost run had thrown an error with the moment-timezone module but reinstalling it or applying a npm update did not achive anything.

After a whole night of downtime what fixed my problem was a complete reinstall of the node modules. rm -rf-ing the node_modules folder, followed by a npm install and a new ghost start got my blog up and running again.

node error while during ghost run

I'm still not sure what happened but in the future I will keep in mind that removing and reinstalling all the node packages can be a solution.

[edit 21.10.2017]
After attempting another Ghost upgrade (this process seems to be the bane of my blogging), I ran yet again into the infamous 502 error and this time npm install did not do the trick.

I tried forcing another update with the command ghost update --force, only to run into the familiar yarn error...

A ProcessError occured.
Error occurred running command: 'yarn install --no-emoji --no-progress'
Exit code: 1

With the ghost client up to date (npm i -g ghost-cli), I then tried to install yarn, even though I really, really do not want to deal with another package manager. Anyway, with yarn installed, the next attempt to force a Ghost update (ghost update --force) finally got my blog up and running!

Yet something tells me this will not be the last edit made to this post...