Upgrade ghost 5.71.0 with node 18, encountered error

Upgrading Ghost to v5.71.0 with Node.js v18.18.2, I encountered database errors when start ghost.

Ghost version 5.70.2 is running smoothly with Node.js 16.20.

+ sudo systemctl is-active ghost_mydomain-com
✔ Checking system Node.js version - found v18.18.2
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_mydomain-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking systemd unit file
✔ Checking systemd node version - found v18.18.2
+ sudo systemctl start ghost_mydomain-com
+ sudo systemctl stop ghost_mydomain-com
✖ Starting Ghost: mydomain-com
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306
Help: Unknown database error
Suggestion: journalctl -u ghost_mydomain-com -n 50

Debug Information:
    OS: Ubuntu, v22.04.3 LTS
    Node Version: v18.18.2
    Ghost Version: 5.71.0
    Ghost-CLI Version: 1.25.3
    Environment: production
    Command: 'ghost start'

Additional log info available in: /home/user/.ghost/logs/ghost-cli-debug-2023-10-27T19_15_29_412Z.log

Try running ghost doctor to check your system for known issues.

The error logs:

[2023-10-27 19:22:46] ERROR connect ECONNREFUSED ::1:3306

connect ECONNREFUSED ::1:3306

"Unknown database error"

Error ID:
    500

Error Code: 
    ECONNREFUSED

----------------------------------------

Error: connect ECONNREFUSED ::1:3306
    at /dir/versions/5.71.0/node_modules/knex-migrator/lib/database.js:57:19
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)

`
Has anyone else encountered a similar situation?

1 Like

Looks like your database isn’t running, or isn’t accepting connections. Can you connect to it on the command line (which would confirm that it’s up)?

1 Like

Yes, I have the same issue.
Still can’t fix it.
Mysql is running,
nodejs is already the newest version (18.18.2-1nodesource1).
Tried ghost setup, still no success

Node 18 prefers ipv6 resolution over ipv4 - you can see this in the error message with the MySQL connection ::1:3306. If your MySQL server isn’t listening on the ipv6 interface then node won’t be able to connect to it.

Quickest fix is probably explicitly specifying 127.0.0.1 for your database host in place of localhost in your Ghost config.

10 Likes

Amazing @Kevin
Thanks a lot! Worked for me.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.