# How to upgrade Node.js for self-hosted Ghost

Tutorial · Norbert · Updated 12 Nov 2026 · 2 min read

Source: https://brightthemes.com/blog/ghost-upgrade-node-18

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

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)](https://brightthemes.com/ghost/pro) 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](https://docs.ghost.org/faq/node-versions) 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](https://brightthemes.com/blog/ghost-install).

Check what you run now:

```bash
node -v
ghost version
```

## 1. Add the NodeSource repository

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

```bash
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`:

```bash
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

```bash
sudo apt-get update
sudo apt-get install nodejs -y
```

Check the version:

```bash
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:

```bash
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:

```bash
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](https://brightthemes.com/blog/ghost-v6). The [Ghost version history](https://brightthemes.com/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](https://forum.ghost.org/t/upgrade-ghost-5-71-0-with-node-18-encountered-error/42246/4) 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:

   ```bash
   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.
