Ghost, Node 18, and ECONNREFUSED ::1:3306

Posted:
Reading time: 1 min read

An appropriately spooky ghost-related update, since we've just had Halloween; when I tried to update the Ghost installation that this blog runs on, I ran into a succession of problems.

I logged into my Digital Ocean droplet that hosts the site and ran the ghost update command to update to Ghost 5.72.0, but it immediately choked on the version of Node that the server was running. There seems to be quite some argument over the inability to easily upgrade to Node 18 (or even 20) on the Digital Ocean forums, but I eventually found a blog post with instructions on how to install it directly via the command line – so I did that, restarted, and ran straight into another, more esoteric, error:

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

It seemed to be having a problem connecting to the MySQL service that should have been running on the server, but running sudo service mysql start didn't report any issues. Luckily, another post on the Ghost forums pointed to the problem (Node 18 uses IPv6 resolution so didn't understand the localhost setting in my site config).

The Ghost-CLI config commands aren't all that clear, unfortunately, but you can easily edit the file yourself by running vi config.production.json in your Ghost install folder and changing the value of database.connection.host. And just like that, we were back in business.

Since I wouldn't have gotten anywhere without others sharing their own experiences and solutions, it's another example of why you should always document your bugfixes, no matter how trivial. And so I'm writing this post, just in case it can help someone else facing the same problem.

Previous post Learning Z80 assembly is hard
Next post To riff or not to riff