503 errors after Upgrade to Ghost v4

Hi,

I opened this thread because I saw on another that it was recommended to open one per user affected.
I tried the solution provided in https://forum.ghost.org/t/upgrade-to-ghost-v4-but-a-lot-of-503-error/20762/31 but it did not solve my case.

Here are my specs:

OS: Ubuntu 20.04.2 LTS
Node Version: v14.16.0
Ghost Version: 4.0.1
Ghost-CLI Version: 1.16.2
Environment: production

Before trying the solution in the link above, I was running node version 10 something.

Here is the output for node:

GhostUser@GhostMachine:/var/www/GhostFolder$ which node
/usr/local/bin/node
GhostUser@GhostMachine:/var/www/GhostFolder$ node --version
v14.16.0
GhostUser@GhostMachine:/var/www/GhostFolder$ /usr/bin/node --version
v14.16.0

Running ghost start, starts Ghost but goes in 503 errors loop, the ghost log command output that ghost restarts every few seconds.
Running ghost run allows the site to stay up.

That is where I am at.
Thank you for your help.


Edit:
node -v command outputs: v12.21.0
Logs in /var/www/ghost/content/logs are too big to be pasted here.

I assume that if you run /usr/local/bin/node --version you will also get v12.21.0

It seems that you have node installed twice:

I think you have node installed twice:

/usr/bin/local/node → v12.21.0
/usr/bin/node → v14.16.0

I have no way to tell why this happened without knowing the history of how node has been installed and used on the server. However the problem is that when you updated node prior to updating Ghost, you have ended up only updating one node install and now Ghost is getting different node versions.

To solve this, you need to either uninstall one version or get them both to be the same.

I deleted the /usr/local/bin/node folder, but the error is still there.

And node -v outputs v14.16.0, which node outpouts /usr/bin/node

And I also followed those steps.

  1. uninstall nvm
  2. reinstall node & npm
  3. reinstall Ghost-CLI
  4. run ghost update 4.0.1 --force

hi @WatsonJH, I finally succeeded to start it, try this:

1 Like

Thanks @mitkomitrovski

I removed with rm -rf the local node folder which then gives me the following output

GhostU@GhostS:/var/www/GhostF$ which node
/usr/bin/node
GhostU@GhostS:/var/www/GhostF$ /usr/bin/node --version
v14.16.0
GhostU@GhostS:/var/www/GhostF$ /usr/local/bin/node --version
-bash: /usr/local/bin/node: No such file or directory

And I also followed those steps.

  1. reinstall Ghost-CLI
  2. run ghost update 4.0.1 --force

ghost start make the ghost instance to restart every second or so.
ghost run makes ghost run well.

I will write how I did it: maybe you can just copy paste from there:

  1. uninstall nvm
    rm -rf $NVM_DIR ~/.npm ~/.bower
    unset NVM_DIR;
    which node;
    rm -rf {path_to_node_version}
    rm -rf {path_to_node_version} (local one also)

  2. reinstall node (I checked where is pointer for node in my settings for me it is without local)
    wget https://nodejs.org/download/release/latest-v12.x/node-v12.21.0-linux-x64.tar.gz sudo tar --strip-components 1 -xzvf node-v* -C /usr/

  3. reinstall Ghost-CLI
    npm install -g ghost-cli@latest

  4. run ghost update 4.0.1 --force

That is it

I do not know what is wrong.

I did as you suggested, I removed the files I also did apt purge nodejs to uninstall it.
I tried with the wget command but it didn’t fixed my issue so I uninstalled node again.
Then I reinstalled node using the Ghost documentation, same for the ghost-cli and did force the ghost update.
I have again:

GhostU@GhostS:/var/www/GhostF$ which node
/usr/bin/node
GhostU@GhostS:/var/www/GhostF$ /usr/bin/node --version
v14.16.0
GhostU@GhostS:/var/www/GhostF$ /usr/local/bin/node --version
-bash: /usr/local/bin/node: No such file or directory

but, it isn’t fixed. :confused:


Edit:
Here is my systemd file

[Service]
Type=simple
WorkingDirectory=/var/www/GhostF
User=999
Environment=“NODE_ENV=production”
ExecStart=/usr/bin/node /usr/bin/ghost run
Restart=always

Lets wait for Hannah, she will know better :smiley:

I tried the latest release (4.1.0), just in case, but no luck.


Edit:
I tried to poke around more and compare how others managed to fix their issue, but for some reason, even if it looks very similar to what they had and I apply their fix, it does not work.
ghost start fails, but ghost run still works fine.

Would you be able to downgrade back to node 12 (assuming that’s what you were on before) following these (updated) instructions: Supported node versions for self-hosted installs of Ghost?

Let’s see if that at least stabilises things and then we can figure out next steps from there.

Hey @Hannah,

Thanks for your help, greatly appreciated. :slight_smile:

I ran the commands based on the link you provided, just changed the 14x by 12x and ran apt purge nodejs prior the reinstall process to remove my version of node.
After running the commands, here is the output I have for node (which to me looks fine):

GhostU@GhostS:/var/www/GhostF$ which node
/usr/bin/node
GhostU@GhostS:/var/www/GhostF$ node --version
v12.21.0
GhostU@GhostS:/var/www/GhostF$ /usr/bin/node --version
v12.21.0
GhostU@GhostS:/var/www/GhostF$ /usr/local/bin/node --version
-bash: /usr/local/bin/node: No such file or directory

I ran the update for ghost 4.1.0, which was the version I was already running, with the force flag. However with ghost start I end up at the same result as before, and ghost run still works as well.

I saw the post by @filijs this morning here: https://forum.ghost.org/t/possible-solution-of-error-502-503-when-upgrading-to-ghost-v4/20943

I tried every command in there and it still did not fix my issue.
I went on https://blog.jonsdocs.org.uk/2019/06/30/problems-with-systemd-ghost-and-node/ to see if it could help, but when I do ghost start and sudo systemctl status ghost_ghost-instance I have a beautiful green light and no errors.

Here is the output:

ghostU@ghostM:/var/www/ghost$ sudo systemctl status ghost_ghost-instance
â—Ź ghost_ghost-instance.service - Ghost systemd service for blog: ghost-instance
Loaded: loaded (/var/www/ghost/system/files/ghost_ghost-instance.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-03-19 08:26:08 EDT; 4s ago
Docs: Ghost: The #1 open source headless Node.js CMS
Main PID: 63516 (node)
Tasks: 22 (limit: 2281)
Memory: 124.9M
CGroup: /system.slice/ghost_ghost-instance.service
├─63516 ghost run
└─63542 /usr/bin/node current/index.js

Mar 19 08:26:08 ghost systemd[1]: Started Ghost systemd service for blog: ghost-instance.
Mar 19 08:26:09 ghost node[63516]: - Inspecting operating system
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Ghost is running in production…
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Your site is now available on hxxps://myghostblog.com/
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Ctrl+C to shut down
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Ghost server started in 0.96s
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Database is in a ready state.
Mar 19 08:26:10 ghost node[63542]: [2021-03-19 12:26:10] INFO Ghost database ready in 1.48s

Here is my /etc/systemd/system/ghost_ghost-instance.service file:

[Unit]
Description=Ghost systemd service for blog: ghost-instance
Documentation=Ghost: The #1 open source headless Node.js CMS

[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=999
Environment=“NODE_ENV=production”
ExecStart=/usr/bin/node /usr/bin/ghost run
Restart=always

[Install]
WantedBy=multi-user.target

I really do not want to have to reinstall my ghost server :confused:

I’m still battling with this issue. :confused:
Going back to node 12 instead of 14 didn’t help. Checking the node install path, it’s seems to be fixed.
Path for systemd looks good as well.

I don’t know where to look anymore.

1 Like

Any update?

Sorry for the delay.
Sadly no :frowning: so now I have deleted my install and I am going another route by deploying ghost using docker.