5.75.1 upgrade fails on Ubuntu 20 with Node 18

It turns out I had multiple problems to resolve.

npm corruption

First, it seems my installation of npm was corrupt. I suspect it happened due to this sequence:

  1. Installed Node 16
  2. Ran sudo npm install -g npm at some point because npm keeps prompting me to upgrade it.
  3. Upgraded Node to version 18.

Node installs it’s own npm, but I think the old npm module directory was left over and conflicting. To resolve that:

sudo apt remove nodejs
sudo rm -rf /usr/lib/node_modules/npm
sudo apt install nodejs

After that npm was unbroken.

IPv6 problems

Next, the upgrade failed like this:

‘Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306’,

Some details in that error: “::1” indicates an IPv6 connection to localhost and “:3306” is the standard port that MySQL listens on.

I believe due to an earlier upgrade to Node 18 or some related module, that connections were now being attempted over IPv6 first. So, although MySQL it was running, it wasn’t listening for IPv6 connnections, so this was failing.

That could be resolved by either forcing Ghost to connect over IPv4, or allowing MySQL to start listening on IPv6 as well. I chose the latter.

The MySQL directive for that is bind-address. In my case, the file to edit was:

/etc/mysql/mysql.conf.d/mysqld.cnf

There was already an entry for bind-address listening on port 127.0.0.1 there. I added a comma and “::1” to the list and restarted MySQL.

After that, my upgrade issues were resolved.