Error connecting to database deploying Ghost docker image

Hello everyone!

I am trying to deploy Ghost instance from latest dockerfile and such on getting the same error:

app[7fea2f05] cdg [info] connect ECONNREFUSED
app[7fea2f05] cdg [info] "Unknown database error"
app[7fea2f05] cdg [info] Error ID:
app[7fea2f05] cdg [info] 500
app[7fea2f05] cdg [info] Error Code:
app[7fea2f05] cdg [info] ECONNREFUSED
app[7fea2f05] cdg [info] ----------------------------------------
app[7fea2f05] cdg [info] Error: connect ECONNREFUSED
 app[7fea2f05] cdg [info] at /var/lib/ghost/versions/5.10.1/node_modules/knex-migrator/lib/database.js:57:19

How can it be fixed? Many thanks for help in advance.

I have the same problem. wanted to deploy ghost v5 and it fails with the database connection error.

It works with the Ghost v4 image

Ghost switched from sqlite3 to Mysql in v5.

BREAKING CHANGE: Switch from sqlite3 to MySQL by default

strangely enough, I have the same issue trying deploy on my local pi with docker-compose. I wonder why there is no solution for docker installs as it seems to be a common error with latest update

as I have mentioned earlier, I have the se issue with a local installation using docker-compose and MySQL in a separate container. multiple installations failed with force shut down of Ghost. the last resort would be a Digital ocean droplet…

and thank you for the tip, I have deployed Ghost 4.8. and it’s working like a charm. And quite enough for my needs at this point!

You can also use “ghost:5.8.2-alpine” as image. This version still uses the sqlite3 as database.

But be aware that is officially is not supported anymore to run in production. Also you will not be able to update the image itself which can lead to security issues in time.

I have tried to run a separate MySQL but this requires a min of 1024 memory and the costs to run this would be to high for me

I’m wondering if there is any way to set the Environment different from Production in the fly.toml. In that way, we can still be using sqlite3, instead of the complexity of MySQL.

I made it work by just adding this to the fly.toml file but it requested me to re-set the password so my blog is still empty so it wasn’t a big deal for me.

NODE_ENV = “development”

Has anyone been able to make Ghost work with MySQL when using Would appreciate to understand your setup.

Answering my own question:
For the sake of others :slight_smile:
MySQL is not part of Ghost’s docker image, so you need to install it separately, when doing that you realize the real issue: MySQl8 needs a lot more RAM than offers and what most hosting platforms offer. Bare minimum one seemingly needs 2GB RAM
Conclusion: Hosting Ghost on’s (free tier) is no longer an option

@patfly you might like this:


Thanks Lubien for sharing

1 Like