question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ECONNREFUSED 127.0.0.1:3306

See original GitHub issue

Issue Summary

Ghost throws an ECONNREFUSED on npm start --production.

Steps to Reproduce

  1. Install Ghost 0.11.7 (not sure if this issue occurs elsewhere.
  2. Run npm install --production.
  3. Run npm start --production.

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead? It should start Ghost without any problems. Instead, I get this jumble:

> ghost@0.11.7 start /var/www/ghost
> node index.js

WARNING: Ghost is attempting to use a direct method to send email. 
It is recommended that you explicitly configure an email service.
Help and documentation can be found at http://support.ghost.org/mail.


ERROR: connect ECONNREFUSED 127.0.0.1:3306 
 
 Error: connect ECONNREFUSED 127.0.0.1:3306
    at Object.exports._errnoException (util.js:870:11)
    at exports._exceptionWithHostPort (util.js:893:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
    --------------------
    at Protocol._enqueue (/var/www/ghost/node_modules/mysql/lib/protocol/Protocol.js:110:48)
    at Protocol.handshake (/var/www/ghost/node_modules/mysql/lib/protocol/Protocol.js:42:41)
    at Connection.connect (/var/www/ghost/node_modules/mysql/lib/Connection.js:98:18)
    at /var/www/ghost/node_modules/knex/lib/dialects/mysql/index.js:106:18
    at Promise._execute (/var/www/ghost/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/var/www/ghost/node_modules/bluebird/js/release/promise.js:481:18)
    at new Promise (/var/www/ghost/node_modules/bluebird/js/release/promise.js:77:14)
    at Client_MySQL.acquireRawConnection (/var/www/ghost/node_modules/knex/lib/dialects/mysql/index.js:104:12)
    at Object.create (/var/www/ghost/node_modules/knex/lib/client.js:231:16)
    at Pool._createResource (/var/www/ghost/node_modules/generic-pool/lib/generic-pool.js:325:17)
    at Pool._ensureMinimum (/var/www/ghost/node_modules/generic-pool/lib/generic-pool.js:363:12)
    at new Pool (/var/www/ghost/node_modules/generic-pool/lib/generic-pool.js:156:8)
    at Client_MySQL.initializePool (/var/www/ghost/node_modules/knex/lib/client.js:261:17)
    at Client_MySQL.Client (/var/www/ghost/node_modules/knex/lib/client.js:108:12)
    at new Client_MySQL (/var/www/ghost/node_modules/knex/lib/dialects/mysql/index.js:62:20)
    at Knex (/var/www/ghost/node_modules/knex/lib/index.js:60:34)
    at Object.<anonymous> (/var/www/ghost/core/server/data/db/connection.js:55:20)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17) 

Technical details:

  • Ghost Version: 0.11.7
  • Node Version: 4.2.6
  • Browser/OS: Google Chrome Version 57.0.2987.133 (64-bit), Ubuntu 16.04 (64-bit)
  • Database: mysql 5.7.17-0ubuntu0.16.04.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
david-zaletanskicommented, Nov 21, 2017

FYI I had the same issue. A bit more specific instructions for anyone else who may not know where to put the property… fixed by opening config.production.json in the ghost directory and adding property just below the… “client”: “mysql”, “connection”: {

The line: “socketPath”: “/var/run/mysqld/mysqld.sock”,

3reactions
HamedMPcommented, Jul 19, 2021

@tyconway I solved it by running mysql in a separate command before ghost start.

sudo /etc/init.d/mysql start

Hi!

I have tried all previously mentioned solutions in this thread and I am still having this problem. Specifically, I don’t have /mysqld/mysqld.sock in my /var/run as @david-zaletanski does. Despite having mysql installed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error "connect ECONNREFUSED 127.0.0.1:3306 ...
I'm new to nodeJs and trying to develop my first application. I installed mysql package through npm, It got installed and I can...
Read more >
Connection Failureconnect ECONNREFUSED 127.0.0.13306 ...
Connection Failureconnect ECONNREFUSED 127.0.0.13306 [Apr 18]
Read more >
Error: connect ECONNREFUSED 127.0.0.1:3306 solved in ...
How to fix Error: connect ECONNREFUSED 127.0.0.1:3306 in node js and mysql is shown.
Read more >
Error: connect ECONNREFUSED 127.0.0.1:3306 - Ask Ubuntu
The reason for this is that you cannot connect to MySQL with the root account anymore. This rule was changed — and enforced...
Read more >
Sudden Error: connect ECONNREFUSED 127.0.0.1:3306
Port 3306 is most commonly used by MySQL - so the error is telling you Ghost can't connect to the DB.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found