502/503 Errors after Ghost v4 Upgrade

Photo by David Pupaza / Unsplash

There are many posts on this and they all have different solutions none of which I wanted to do because of the extent of packages that needed to be removed and reinstalled.

Most of these posts have the same initial observations. The user is getting 503/502 errors after an upgrade to Ghost v4 and they don't know why. They can run ghost run at the command line and it works fine but when they run ghost start they get these errors. Some users found upgrading the size of their VM's fixed the problem, others removed and reinstalled node and ghost. When looking at my systemd configuration I noticed a difference in where the ghost command and node commands were being ran from. When I ran at the command line they were out of /usr/local/bin/ghost and /usr/local/bin/node where as when they were ran by systemd they were being ran from /usr/bin/ghost and /usr/bin/node ... modifying the systemd configuration file located in /lib/systemd/system/ghost_<url> and changing the ExecStart line to look like below.

[Unit]
Description=Ghost systemd service for blog: <blog url>
Documentation=https://ghost.org/docs/

[Service]
Type=simple
WorkingDirectory=/var/ww/ghost
User=999
Environment="NODE_ENV=production"
ExecStart=/usr/local/bin/node /usr/local/bin/ghost run
Restart=always

[Install]
WantedBy=multi-user.target

Once this is done execute sudo systemctl daemon-reload followed by ghost start once this was done the site was back up and running without any issues.

Ben Grewell

Ben Grewell