Mysql ECONNREFUSED after a while

Hi,

When I install and deploying ghost I have no problem, I created some article smoothly.
but after a while when ghost don’t have any request and when I try to load the blog, I have this error:

[2023-02-02 09:10:36] ERROR

CODE: ECONNREFUSED
MESSAGE: connect ECONNREFUSED 127.0.0.1:3306

Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)

After the first attempt to load the blog ghost reload and can connect with any problem to Mysql and the blog is working again.
I also have no error on Mysql.

I have Mysql on docker and ghost in the host (Raspberry Pi 3 Model B Rev 1.2)
This is my docker-compose:

  mysql:
    image: mysql:8
    restart: always
    command: mysqld --default-authentication-plugin=mysql_native_password
    ports:
      - "3306:3306"
    volumes:
      - ./ghost-db/:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: xxxx

My config.production.json

  "url": "https://blog.nextmiracle.eu",
  "server": {
    "port": 8081,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "127.0.0.1",
      "user": "root",
      "password": "xxxx",
      "database": "ghost"
    }
  },
  "mail": {
    "transport": "Direct",
    "options": {
      "service": "Mailgun",
      "host": "xxxx",
      "port": 587,
      "secure": false,
      "auth": {
        "user": "xxxx",
        "pass": "xxxx"
      }
    }
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/home/xxx/ghost/ghost-web/content"
  }
}

With latest Ghost: 5.33.3, Node: v16.19.0, Npm: 9.3.1
and my system is up to date with the latest rasbian kernel

Any help / though will be appreciate

My guess is you are running out of memory.

When you can’t connect to MySQL, is it still running? How much memory is free?

Hi, thanks for your reply.

I will check that when the blog is down, but in my RPI I have 1GB of memory and 1GB of swap,
Right now the blog is working correctly and I have ~800MB free memory (with 270MB of RAM).

Do Ghost have a hard coded limit of free memory it need ?

I also have 44GB of space on my SD card.

Ghost requires 150 MB free memory for maintenance tasks but I don’t believe there’s a limit while it’s running.

In this case, the logs and resources available around the time of the problem will be what’s interesting.

Ok, I finally found the problem !
It’s look like have some problem with Docker-rootless when the network interface changed name on Debian.
I’m not an expert in this subject, but I fix that by reinstalling Docker without rootless, and now it’s working for few days without any downtime.

Thanks, @markstos is because I want to monitor the resource available for MySQL, then I see the history of the journalctl and other stuff and see the error.