Possible solution of error (502/503) when upgrading to Ghost v4

Hello!

I like many here in the forum, when updating Ghost to version 4 I had an error on my site, which threw a 502/503 error or possibly also launched the message “We’ll be right back”.

Well, after spending a couple of hours trying to fix it, I finally came up with a solution that worked for me and I share it with you, to see if it works anyway for you.

It should be noted that I am using Ubuntu with DigitalOcean, but don’t be alarmed, just try to adapt the steps to the distribution or place where you have Ghost installed.

Note: If you are using DigitalOcean, I recommend you follow the steps with the ghost-mgr user. In the event that you do not have this user, just be careful with the permissions, especially if you are with root.

1. Remove Ghost-CLI

The first thing I did was remove the Ghost-CLI, using npm.

$ npm uninstall ghost-cli --global

Make sure you no longer have it, run any ghost command and get an error as a result.

2. Uninstall node

The following is to do the same, but with nodejs.

If you are using nvm

nvm already brings problems to Ghost by installing it locally in / root or / home, so it would be best not to use it and choose to install node in the usual way.

Make sure you know the current breadcrumb of Node first, then remove it.

$ nvm which 14.0 # Just make sure you use the version you have

Later we proceed to uninstall:

$ rm -rf $NVM_DIR ~/.npm ~/.bower
$ unset NVM_DIR;
$ which node;
$ rm -rf {path_to_node_version} # The route that we previously took

Open ~/.bash_profile or ~/.bashrc and remove any nvm lines.

If you are using node without nvm

For the second case, node would have to be removed from the system. In my case, I installed it with apt-get, so I removed it in the same way.

$ sudo apt-get remove nodejs

To remove both the package and the configuration files run:

$ sudo apt-get purge nodejs

As a final step, you can run the command below to remove any unused files and free up the disk space

$ sudo apt-get autoremove

3.Install node & npm

Well, now we are going to reinstall Nodejs, in the traditional way and without nvm. In my case, that I am with Ubuntu, I will use apt-get.

To start off, add the NodeJS PPA to your system using the following commands.

$ sudo apt-get install software-properties-common

Next, add the NodeJS PPA.

Version v12.21.0 worked for me, I have also seen that version 12.x is recommended for this problem. So I also recommend doing the same.

$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

It’s time now to install NodeJS using the command below.

$ sudo apt-get install nodejs

Verify that everything is working correctly.

$ node -v

4. Reinstall Ghost-CLI

$ sudo npm install -g ghost-cli@latest

5. Update Ghost again

Finally update Ghost again to version 4 (/var/www/ghost).

$ ghost update --force

And finally run start

$ ghost start

Bonus

As a bonus, another common problem that I have seen related to the same issue is the systemd. For this I leave you the following article that can help with that problem.

Well, I hope this has solved the problem for you, it worked for me and I would like it to be so with you.

Greetings :wave:!

References

3 Likes

Thanks for the tutorial @filijs! I have one question: would removing ghost-cli also remove my ghost installation? Or would I be able to run the same blog using the same database, same /var/www/ghost folder after reinstall? I have a blog with lots of images and posts that I really don’t want to lose.

Hi @bop, as long as you uninstall Ghost-CLI, using the $ npm uninstall command, you should have no problem with your files in / var / www / ghost. I did it like that with mine. Either way, I recommend that you always make backup copies.

Thanks for the detailed steps.
Sadly for me it did not fix it. I still have the same behaviour. My thread :confused:

1 Like

Thanks for your help. I’ve gone through your list and unfortunately I still have the same issue. My site only works when I do ghost run. Doing ghost start provokes constant 502 errors and server reboots.

1 Like