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
1 Like

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

If I’m using an instance of mysql on my Plesk server, what should the database host IP be? I’ve tried the server public IP address and the private IP for the server and I’m still getting a connection error.

@FifthRate Neither. By default, the networking inside the docker container can’t reach the networking on the host. I don’t run Ghost on Docket, but there are a number of tutorials on it:

https://www.google.com/search?hl=en&q=docker%20ghost%20MySQL

Another option is to update your MySQL networking (if you have MySQL 8.0.13 or newer) to listen on a private IP that the Docker container can see. You are own your own for figuring out what the correct IP for that might be.

I published how I expected MySQL to the private IP range of containers here. But I use podman not Docker.

Hello champion. Can assist on how you were able to install ghost on your plesk server? What resources did you follow? Pls if you have a few minutes, could walk me through the steps? I have Ghost downloaded with docker by it is not able to connect to the database(mysql) when I start it.