Update to latest version failed connect ECONNREFUSED ::1:3306

ubuntu 20.04

I was using version 5.69.1, I ran the ghost update command, I got an error due to nodejs 16, so I updated to nodejs 18.x

I gave ghost update again, something went wrong, it suggested me to rollback but that didn’t work either.

now ghost is not reachable, nginx gives me “502 Bad Gateway”, and the ghost error log gives me this:

"message":"connect ECONNREFUSED ::1:3306","help":"\"Unknown database error\"","stack":"Error: connect ECONNREFUSED ::1:3306\n at /var/www/ example/versions/5.71.0/node_modules/knex-migrator/lib/database.js:57:19\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)","hideStack":false} ,"msg":"connect ECONNREFUSED ::1:3306","time":"2023-10-31T01:19:41.091Z","v":0}

I downgraded nodejs to version 16.x, I tried upgrading and downgrading again but something doesn’t work. In the “versions” folder I correctly have versions 5.71.0 and 5.69.1

now I get the following error:

✖ Checking systemd node version
One or more errors occurred.

1) SystemError

Message: Unable to determine node version in use by systemd
Help: Ensure 'ExecStart' exists in /lib/systemd/system/ghost_example-it.service and uses a valid Node version

Debug Information:
     OS: Ubuntu, v20.04.5 LTS
     Node Version: v16.14.2
     Ghost Version: 5.69.1
     Ghost-CLI Version: 1.25.2
     Environment: production
     Command: 'ghost doctor'

I changed the new path in the .service file:

ExecStart=/home/user/.nvm/versions/node/v16.14.2/bin/node /usr/bin/ghost run

ghost doctor does not give errors:

✔ Checking system Node.js version - found v16.14.2
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_example-it
+ sudo systemctl reset-failed ghost_example-it
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file

I managed to start it without making any further changes, I restarted the server.
now I use nodejs 16.x with the new path and ghost version 5.69.1

How should I proceed to avoid finding myself in the same panic?

Please search the forum to find similar topics. For node 18, you need to update your config because of a breaking change in node.js:

I searched, maybe in a panic I didn’t see anything, the solution seems simple, change from localhost to, thanks