# Plesk -\> Docker -\> Ghost -\> My SQL

**URL:** <https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038>\
**Category:** Installation\
**Created:** [November 4, 2020, 6:07pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038 "2020-11-04T18:07:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taxick](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/taxick/32/10960_2.png) [@Taxick](https://forum.ghost.org/u/Taxick)\
**Post date:** [November 4, 2020, 6:07pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/1 "2020-11-04T18:07:00Z")

</div>

Hi 🙂

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

 ![config](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/9/9e782e3d8bc26836294c86113dc0e39ea0909580.png)

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
```

---

<div class="post-metadata">

**Author:** ![Taxick](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/taxick/32/10960_2.png) [@Taxick](https://forum.ghost.org/u/Taxick)\
**Post date:** [November 5, 2020, 2:56pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/2 "2020-11-05T14:56:37Z")

</div>

Can someone help me?

---

<div class="post-metadata">

**Author:** ![acburdine](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/acburdine/32/4825_2.png) [@acburdine](https://forum.ghost.org/u/acburdine)\
**Post date:** [November 6, 2020, 7:28pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/3 "2020-11-06T19:28:38Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Taxick](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/taxick/32/10960_2.png) [@Taxick](https://forum.ghost.org/u/Taxick)\
**Post date:** [November 9, 2020, 2:29pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/4 "2020-11-09T14:29:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![FifthRate](https://avatars.discourse-cdn.com/v4/letter/f/6a8cbe/32.png) [@FifthRate](https://forum.ghost.org/u/FifthRate)\
**Post date:** [January 13, 2023, 4:48pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/5 "2023-01-13T16:48:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [January 13, 2023, 6:54pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/6 "2023-01-13T18:54:26Z")

</div>

@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](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.

> **[Self-hosting Matomo with a shared MySQL database](https://mark.stosberg.com/self-hosting-matomo-with-a-shared-mysql-database/)**
>
> The official way to self-host Matomo Analytics is using it's own dedicated MySQL container along with a container for Matomo. I'm hosting it on a VPS with limited resources that's already running a MySQL database, so I wanted Matomo to connect to the...

---

<div class="post-metadata">

**Author:** ![Skill\_Embassy](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/skill_embassy/32/25388_2.png) [@Skill\_Embassy](https://forum.ghost.org/u/Skill_Embassy)\
**Post date:** [November 21, 2023, 6:41pm UTC](https://forum.ghost.org/t/plesk-docker-ghost-my-sql/18038/7 "2023-11-21T18:41:42Z")

</div>

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.
