Plesk -> Docker -> Ghost -> My SQL

Hi :slight_smile:

I’m trying to setup MySQL in Ghost on docker.

  • I’m using the last version of the official ghost image on docker

My environment variables:

database__client: mysql
database__connection__host: localhost
database__connection__user: admin_futurenode
database__connection__password: MYSCRECTPASSWORD
database__connection__database: admin_futurenode

I running the last version of Plesk hosting panel with docker

But when I try to run ghost I get this error

[2020-11-04 18:06:10] e[31mERRORe[39m connect ECONNREFUSED 127.0.0.1:3306
e[31m
e[31mconnect ECONNREFUSED 127.0.0.1:3306e[39m

e[33m"Unknown database error"e[39m

e[1me[37mError ID:e[39me[22m
    e[90m500e[39m

e[1me[37mError Code: e[39me[22m
    e[90mECONNREFUSEDe[39m

e[90m----------------------------------------e[39m

e[90mDatabaseError: connect ECONNREFUSED 127.0.0.1:3306
    at DatabaseError.KnexMigrateError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:7:26)
    at new DatabaseError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:55:26)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/database.js:48:19

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
    --------------------
    at Protocol._enqueue (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/Connection.js:116:18)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:69:18
    at Promise._execute (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:103:10)
    at Client_MySQL.acquireRawConnection (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:64:12)
    at create (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/client.js:291:39)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)e[39m
e[39m
[2020-11-04 18:06:13] e[31mERRORe[39m connect ECONNREFUSED 127.0.0.1:3306
e[31m
e[31mconnect ECONNREFUSED 127.0.0.1:3306e[39m

e[33m"Unknown database error"e[39m

e[1me[37mError ID:e[39me[22m
    e[90m500e[39m

e[1me[37mError Code: e[39me[22m
    e[90mECONNREFUSEDe[39m

e[90m----------------------------------------e[39m

e[90mDatabaseError: connect ECONNREFUSED 127.0.0.1:3306
    at DatabaseError.KnexMigrateError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:7:26)
    at new DatabaseError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:55:26)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/database.js:48:19

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
    --------------------
    at Protocol._enqueue (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/Connection.js:116:18)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:69:18
    at Promise._execute (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:103:10)
    at Client_MySQL.acquireRawConnection (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:64:12)
    at create (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/client.js:291:39)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)e[39m
e[39m
[2020-11-04 18:06:15] e[31mERRORe[39m connect ECONNREFUSED 127.0.0.1:3306
e[31m
e[31mconnect ECONNREFUSED 127.0.0.1:3306e[39m

e[33m"Unknown database error"e[39m

e[1me[37mError ID:e[39me[22m
    e[90m500e[39m

e[1me[37mError Code: e[39me[22m
    e[90mECONNREFUSEDe[39m

e[90m----------------------------------------e[39m

e[90mDatabaseError: connect ECONNREFUSED 127.0.0.1:3306
    at DatabaseError.KnexMigrateError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:7:26)
    at new DatabaseError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:55:26)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/database.js:48:19

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
    --------------------
    at Protocol._enqueue (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/Connection.js:116:18)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:69:18
    at Promise._execute (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:103:10)
    at Client_MySQL.acquireRawConnection (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:64:12)
    at create (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/client.js:291:39)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)e[39m
e[39m
[2020-11-04 18:06:18] e[31mERRORe[39m connect ECONNREFUSED 127.0.0.1:3306
e[31m
e[31mconnect ECONNREFUSED 127.0.0.1:3306e[39m

e[33m"Unknown database error"e[39m

e[1me[37mError ID:e[39me[22m
    e[90m500e[39m

e[1me[37mError Code: e[39me[22m
    e[90mECONNREFUSEDe[39m

e[90m----------------------------------------e[39m

e[90mDatabaseError: connect ECONNREFUSED 127.0.0.1:3306
    at DatabaseError.KnexMigrateError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:7:26)
    at new DatabaseError (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/errors.js:55:26)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/lib/database.js:48:19

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
    --------------------
    at Protocol._enqueue (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/var/lib/ghost/versions/3.37.1/node_modules/mysql/lib/Connection.js:116:18)
    at /var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:69:18
    at Promise._execute (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/var/lib/ghost/versions/3.37.1/node_modules/bluebird/js/release/promise.js:103:10)
    at Client_MySQL.acquireRawConnection (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:64:12)
    at create (/var/lib/ghost/versions/3.37.1/node_modules/knex-migrator/node_modules/knex/lib/client.js:291:39)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)e[39m
e[39m

Can someone help me?

@Taxick the reason you’re likely seeing this is that Docker by default isolates containers in their own network space, so localhost inside the container doesn’t map to localhost of the server.

How are you running MySQL? Is it running in another Docker container alongside the Ghost container, or is it running on its own separate from Docker? The fix will be different based on how you’re running MySQL

You right - after i change the localhost to my database IP i works

1 Like