DB connection failed after months of working and without updating

I run 4 ghost blogs in a docker-compose variation. All 3 of them at around 1000 local today stopped working. All 3 of them had the same error:

Invalid DB Host

Error ID:
500

I updated both the DB and the Ghost image and I get this error on two of them.

Invalid database host.
0=P 1=l 2=e 3=a 4=s 5=e 6=  7=d 8=o 9=u 10=b 11=l 12=e 13=  14=c 15=h 16=e 17=c 18=k 19=  20=y 21=o 22=u 23=r 24=  25=d 26=a 27=t 28=a 29=b 30=a 31=s 32=e 33=  34=c 35=o 36=n 37=f 38=i 39=g 40=. 
Error ID:
    500
Error Code: 
    EAI_AGAIN
----------------------------------------
Error: getaddrinfo EAI_AGAIN db
    at /var/lib/ghost/versions/5.120.2/node_modules/knex-migrator/lib/database.js:50:23
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
[2025-05-24 18:32:23] WARN Ghost is shutting down
[2025-05-24 18:32:23] WARN Ghost has shut down
[2025-05-24 18:32:23] WARN Your site is now offline
[2025-05-24 18:32:23] WARN Ghost was running for a few seconds

On another I just updated the Ghost image and that one seems to work just fine now, however I am getting this occasionally

[2025-05-24 18:28:23] INFO Running milestone emails job on Tue May 27 2025 18:28:23 GMT+0000 (Coordinated Universal Time)
[2025-05-24 18:28:25] WARN {{#get}} helper took 215ms to complete
{{#get}} helper took 215ms to complete

All of them have the same compose file with different passwords and ports, but identical outside of that. I have no idea what happened. Host is MFA secured and logs show no logins except me attempting to figure it out. How can I stop this from happening again? How do I even see what happened?

I am not sure what information you’ll need so here is what I can give you.

Host: Ubuntu 20.04
Version: 5.120.2
Environment: production
Database: mysql8
Mail: SMTP

Thank you for your help.

EAI_AGAIN is a DNS lookup error, so it’s either something with your docker network, or your host DNS that’s preventing the database host from being translated in to an IP address

1 Like

How would I check that? Nothing changed in the network settings. That are on the same docker-compose file.

I can’t help too much with debugging Docker network issues, but I would start by trying to e.g. ping the DB host in your Ghost container image

I problem is that it keeps rebooting since it can’t connect to the DB

Any other ideas? The container just restarts if it can’t connect to the DB. This is my docker compose file

ghost:
    image: ghost:latest
    restart: always
    ports:
      - 2369:2368
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: [REDACTED]
      database__connection__password: [REDACTED]
      database__connection__database: ghost
      url: [REDACTED]
      mail__transport: SMTP
      mail__from:[REDACTED]
      mail__options__service: Mailgun
      mail__options__host: smtp.mailgun.org
      mail__options__port: 587
      mail__options__secureConnection: false
      mail__options__auth__user: [REDACTED]
      mail__options__auth__pass: [REDACTED]
    volumes:
      - [REDACTED]
    links:
      - db

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: [REDACTED]
      MYSQL_DATABASE: ghost
      MYSQL_USER: [REDACTED]
      MYSQL_PASSWORD: [REDACTED]
    volumes:
      - [REDACTED]

It’s been a while since I debugged Docker image issues, that’s all I’ve got for now :upside_down_face: