Connect ECONNREFUSED ::1:3306

I have 2 more ghost installations running perfectly on the same server with different ports. The Database credentials are correct. Not sure what’s wrong.

  • What version of Ghost are you using? 5.51.1

  • What errors or information do you see in the console?

✖ Starting Ghost
One or more errors occurred.

1) ConfigError

Error detected in the production configuration.

Message: connect ECONNREFUSED ::1:3306
Configuration Key(s): database.connection.host / database.connection.port
Current Value(s): localhost / 3306

Help: Ensure that MySQL is installed and reachable. You can always re-run `ghost setup` to try again.


2) GhostError

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

Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v18.16.0
    Ghost Version: 5.46.0
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost setup'

Additional log info available in: /home/mysite/.ghost/logs/ghost-cli-debug-2023-06-14T02_55_43_976Z.log

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

When I run ghost doctor


✔ Checking system Node.js version - found v18.16.0
✔ 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_mysite-com
? Sudo Password [hidden]
✔ 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
✔ Checking systemd node version - found v18.16.0

Here is the additional log:

Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v18.16.0
    Ghost Version: 5.46.0
    Ghost-CLI Version: 1.24.0
    Environment: production
    Command: 'ghost setup'
Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306
Help: Unknown database error
Suggestion: journalctl -u ghost_mysite-com -n 50
Stack: Error: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306
    at Server.<anonymous> (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:73:28)
    at Object.onceWrapper (node:events:627:28)
    at Server.emit (node:events:513:28)
    at emitCloseNT (node:net:2135:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

It was due to node v18.x working after downgrading to v16.x

v16 stopped supporting latest ghost;
consider to change the host to 127.0.0.1 (localhost may resolve to an ipv6 addr [::1:3306] which is failing as above error shows)

Thank you for the info about v16 not supported anymore.

I would like to follow these instructions to update, but I got errors. So tried to backup before upgrading, but I get this message after running Ghost backup :

Debug Information:
OS: Ubuntu, v22.04.1 LTS
Node Version: v16.17.0
Ghost Version: 5.59.4
Ghost-CLI Version: 1.24.2
Environment: production
Command: ‘ghost backup’
Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED 127.0.0.1:3306
Help: Unknown database error
Suggestion: journalctl -u ghost_lahallebarde-com -n 50
Stack: Error: Ghost was able to start, but errored during boot with: connect ECONNREFUSED 127.0.0.1:3306
at Server. (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:73:28)
at Object.onceWrapper (node:events:627:28)
at Server.emit (node:events:513:28)
at emitCloseNT (node:net:1820:8)
at processTicksAndRejections (node:internal/process/task_queues:82:21)

Does anybody is facing the same problem ?

This should fix it :slight_smile:

2 Likes