1 min read

Resolving Ghost and Caprover Error 500: ECONNRESET

Resolving Ghost and Caprover Error 500: ECONNRESET

If you have just newly setup Ghost on Caprover via the one-click app script, and visiting the ghost site intermittently returns the error:

select count(distinct posts.id) as aggregate from `posts` where (`posts`.`status` = 'published') and (`posts`.`page` = false) - read ECONNRESET
Ghost Error Messagec

but recovers immediately after, it's due to a incorrect config on Ghost highlighted here, causing the DB to disconnect after 10 minutes of inactivity.

The solution (as highlighted in the commit), is to disable pool by adding:

"pool": {
	"min":0
 }

in config.production.json.

I modified the file by figuring out the mountpoint of the Docker volume and editing it with vim. Probably not recommended but eh.

// list all available docker volumes
root@server:/# docker volume ls
DRIVER    VOLUME NAME
local     captain--ghost-data
local     captain--ghost-mariadb-data

// get mount point of ghost volume
root@server:/# docker volume inspect captain--ghost-data
[
    {
        "CreatedAt": "2021-02-22T13:55:32Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/captain--ghost-data/_data",
        "Name": "captain--ghost-data",
        "Options": null,
        "Scope": "local"
    }
]

// add pool:{min: 0} to the database JSON key
root@server:/# vim /var/lib/docker/volumes/captain--personal-data/_data/ghost/config.production.json

{
  "database": {
    "client": "mysql",
    "connection": {
      "host": "host",
      "port": 1234,
      "password": "password",
      "user": "user",
      "database": "database"
    },
+   "pool": {
+      "min": 0
    }
  },

Restart the ghost instance by going to the web dashboard of Caprover, selecting your app, then click on "Save Configuration & Update" button.

Hope this helps!