/ Tech Ideas

Ghost Blog 502 Error after upgrading

和功夫-W与出bug的Ghost Blog战了一天

Wasted a whole afternoon on fixing 502 Bad Gateway for Ghost Blog.

Strange as it appears to be, npm start --production worked for me yet service ghost start does not. I did upgrade both node and Ghost Blog today and I was extremely confused by the symptom of this bug (like what the hell is the difference between service and npm start?).

Skip to the conclusion: the problem is caused by upgrading the node. When I upgraded it, I used n (it's like a node version manager which allows you to switch between different versions of node), which changed the directory of the node my OS uses.

If you use service script to keep the blog online:

  1. run which node to find the directory of node, mine gives: /usr/local/bin/node
  2. vim(or nano as you may like) /etc/init.d/ghost
    mine appears to be:
export NODE_ENV=production

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
  1. Change DAEMON=/usr/bin/node into DAEMON=/usr/local/bin/node and everything will be fine again.
Akako L

Akako L

• Sophmore, HEP-ex Physics • Zelda, Splatoon • Casual Photography and OSU! • Decade-long DotA 2 player • Love Japanese Culture

Read More
Ghost Blog 502 Error after upgrading
Share this

Subscribe to The WOrLd