Skip to content

40%off everything for Black Friday, with code . Until Dec 1.

Bright Themes

How to upgrade Node.js for self-hosted Ghost

Move your self-hosted Ghost site to the Node.js version Ghost requires, reinstall its dependencies, and fix the errors that can follow.

Norbert2 min read

Each major Ghost version supports only a few Node.js versions, and Ghost drops old ones as they reach end of life. Ghost 6 runs on Node.js 22 or 24, the two LTS versions Ghost supports: Node.js 18 and 20 no longer work, and Node.js 24 has been supported since Ghost 6.63. Ghost also raises the minimum release of each from time to time, to pick up Node.js security fixes. When it does, you upgrade Node.js on your server first, then update Ghost.

It pays to stay on a supported version: it’s the one Ghost tests, and the one it fixes issues for. Ghost(Pro) (opens in a new tab) runs the recommended version for you.

This guide is for sites installed with Ghost-CLI on Ubuntu, Ghost’s recommended stack. With Ghost’s Docker setup, Node.js comes with the Ghost image, so you only update the image.

What you need

  • SSH access to your server, as a user with sudo rights (not root).
  • The Node.js version your Ghost version needs. Check Ghost’s supported Node versions (opens in a new tab) page; in November 2026 that is Node.js 22 or 24, at a recent release.
  • A recent backup: run ghost backup in your Ghost folder.

Setting up a new server instead? Follow How to install Ghost with Ghost-CLI.

Check what you run now:

Terminal
node -v
ghost version

1. Add the NodeSource repository

Ghost’s install guide uses Node.js from NodeSource. Download and import its signing key:

Terminal
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

Then add the repository for the Node.js major version you need. Set NODE_MAJOR to it, 22 or 24:

Terminal
NODE_MAJOR=22
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

If you already have a nodesource.list file from an earlier version, this replaces it. To move to a newer release of the same major version, skip this step: step 2 installs the latest release.

2. Install the new Node.js

Terminal
sudo apt-get update
sudo apt-get install nodejs -y

Check the version:

Terminal
node -v

3. Reinstall Ghost’s dependencies

Ghost has binary dependencies that are compiled for one Node.js version. After a Node.js upgrade they must be reinstalled, or Ghost fails to start with strange errors.

Don’t update Node.js and Ghost in one go. Reinstall the Ghost version you already run first. Go to your Ghost folder (for example /var/www/sitename) and run:

Terminal
ghost version
ghost update 6.x.x --force

Replace 6.x.x with the version that ghost version shows. --force reinstalls that version and its dependencies.

4. Update Ghost

Once Ghost runs on the new Node.js, update it as usual:

Terminal
ghost update

If you’re moving to a new major version, read its breaking changes first, for example Ghost 6: what’s new for publishers. The Ghost version history lists what each release changed.

Fix common errors

Unsupported version of Node

Text
ERROR: Unsupported version of Node

You may also see Exit status 231. Ghost doesn’t support the Node.js version you installed. Check the supported versions and repeat steps 1 and 2 with the right NODE_MAJOR.

connect ECONNREFUSED ::1:3306

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

Newer Node.js versions resolve localhost to the IPv6 address ::1 first. If MySQL only listens on IPv4, Ghost can’t reach it. See the Ghost forum thread (opens in a new tab) on this error.

The fix is to point Ghost at the IPv4 address:

  1. Open config.production.json in your Ghost folder.

  2. In the database section, change host from localhost to 127.0.0.1:

    JSON
    "database": {
      "client": "mysql",
      "connection": {
        "host": "127.0.0.1",
        "user": "your_user",
        "password": "your_password",
        "database": "your_database"
      }
    }
  3. Restart Ghost:

    Terminal
    ghost restart

The result

Your server runs the Node.js version Ghost requires, Ghost’s dependencies are rebuilt for it, and you can keep updating Ghost as usual.

Related posts

More on hosting

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.