We previously explain how node and npm can be updated on this post. However, we recently ran into an issue while trying to update Ghost to the to the latest version 5.78.0.

Everything started with one little command that is usually super simple to launch with Ghost in order to update the blog

ghost update

We ran automatically into an error related to the current Node version that was not compatible with Ghost 5.78.0.

Ghost v5.78.0 is not compatible with the current Node version. Your node version is 16.20.2, but Ghost v5.78.0 requires ^18.12.1

Node 14 support was dropped by Ghost v5.47.0 and recommended version is now 18.x (Node v18 Hydrogen LTS). It was not super clear to us at the beginning because recommended version is actually the only one supported at the moment of this article. If you need more details, Ghost wrote about supported Node versions on this article.

Ghost uses the recommended version of Node.js in production on Ghost(Pro) which means it’s heavily tested and issues are actively fixed by the Ghost core team.

Running Ghost on the latest version of Node.js may not provide guaranteed compatibility, and regrettably, we cannot provide support for potential issues. Ghost operates with a small team, prioritizing minimal version support to allocate more time for the development of exciting new features πŸƒβ€β™€οΈ.

You can access compatible Node.js versions by visiting the Node.js releases page. Additionally, you have the option to install multiple Node.js versions using tools like nave or nvm.

Digital Ocean used to have Node 14.x with their Ghost One-Click Droplet as Tabloid is hosted with them. If you are hosting your Ghost blog on one of those droplets, you won't be able to update to the latest version of Ghost until you upgrade your Node.js version to either Node 16 or Node 18.

Knowing that Node 18 is the latest LTS version, we decided to make the big jump from Node 14... You know problems are coming, right?

the back of a woman's head with a multicolored pattern
Photo by Maxim Berg / Unsplash

Upgrade Node

When upgrading Node.js, it's essential to follow a two-step process: first, update Node.js itself, and then re-install Ghost's dependencies. Ghost relies on various binary dependencies compiled for a specific Node.js version, and not re-installing them may result in startup failures accompanied by cryptic error messages.

To perform the upgrade, follow these steps:

  1. Begin by downloading and importing the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  1. Create deb repository
NODE_MAJOR=18 # Use a supported version echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
  1. Run update and install
sudo apt-get update
sudo apt-get install nodejs -y
  1. Run ghost version to get your current Ghost version
  2. ghost update 5.78.0 --force to force Ghost to reinstall your current version of Ghost, to trigger a re-install of dependencies.
a stylized image of a cube with many smaller cubes
Photo by Vighnesh Dudani / Unsplash

It was where the issue started... Ghost was able to run with no issue but MySQL service was having issues.

Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306
Help: Unknown database error

It appeared to encounter an issue when attempting to establish a connection with the MySQL service, which should have been active on the server. However, running 'sudo service mysql start' did not report any problems.

Fortunately, we found a solution through another post on the Ghost forums and Matthew explained it very well on his piece of insightful paper. The issue was that Node 18 was using IPv6 resolution, causing it not to recognize the 'localhost' setting in my site configuration.

The Ghost-CLI configuration commands lack clarity, but you can take matters into your own hands.

  1. Access the configuration file directly by executing 'vi config.production.json' or 'nano config.production.json' (my fav) within your Ghost installation directory.
  2. Modify the value of 'database.connection.host' as needed. With these adjustments, your system will be up and running smoothly once again.

Overview of config.production.json while inside your Ghost installation

"database": {
"client": "mysqlclient",
"connection": {
"host": "", <---- this was set as 'localhost' before the fix
"user": "user",
"password": "pwd",
"port": 3306,
"database": "nameofthedb"

Very important to always document bugfixes and follow the journey from the beginning with references and screenshots. It helps the community ❀️

Share this post