Could not load content

Sometimes the content on my site doesn’t load and I see a picture like this


What could this be and what is the best way to fix it?

The “Could not load content” is usually related to an aborted database query – so, that’s where I’d start looking.

How are you hosting Ghost?
And if you’re self-hosting: what do your logs say?

Yes, I hosting Ghost

Using ghost log -f I found the following errors:

[2024-04-22 05:47:45] ERROR

NAME: HelperWarning
CODE: ABORTED_GET_HELPER
MESSAGE: {{#get}} took longer than 5000ms and was aborted

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:news","include":"tags","limit":"5","context":{"member":null}}}


[2024-04-22 05:47:45] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 5022ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:news","include":"tags","limit":"5","context":{"member":null}},"returnedRows":0}


[2024-04-22 05:47:45] ERROR

NAME: HelperWarning
CODE: ABORTED_GET_HELPER
MESSAGE: {{#get}} took longer than 5000ms and was aborted

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:articles","include":"tags","limit":"5","context":{"member":null}}}


[2024-04-22 05:47:45] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 5022ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:articles","include":"tags","limit":"5","context":{"member":null}},"returnedRows":0}


[2024-04-22 05:47:45] ERROR

NAME: HelperWarning
CODE: ABORTED_GET_HELPER
MESSAGE: {{#get}} took longer than 5000ms and was aborted

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:videos","include":"tags","limit":"5","context":{"member":null}}}


[2024-04-22 05:47:45] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 5022ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:videos","include":"tags","limit":"5","context":{"member":null}},"returnedRows":0}


[2024-04-22 05:47:45] ERROR

NAME: HelperWarning
CODE: ABORTED_GET_HELPER
MESSAGE: {{#get}} took longer than 5000ms and was aborted

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:papers","include":"tags","limit":"5","context":{"member":null}}}


[2024-04-22 05:47:45] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 5023ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:papers","include":"tags","limit":"5","context":{"member":null}},"returnedRows":0}


[2024-04-22 05:47:46] WARN

where and what logs should I look at?
the instance on which the site runs has enough resources and there are no problems with critical resource usage in its monitoring.

The issue is that the #get helper takes too long and Ghost aborts after 5 seconds.

In the error details I can see that every helper only fetches 5 posts:

So, in my eyes, the issue isn’t with Ghost, but with your database. If it takes over 5 seconds to fetch 5 posts, something is wrong there.

As a quick comparison: I am hosting Ghost websites on a server that is physically a few hundred kilometres from the server that’s hosting than the MySQL database and a request like that usually takes around 100ms max.

For the test, I configured the database in AWS RDS and also add to the config

    "pool": {
      "min": 2,
      "max": 2000
    }

but I still get the same errors when the site is under heavy load

[2024-05-07 06:01:29] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 1077ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"include":"authors,tags","limit":"6","context":{"member":null}}}


[2024-05-07 06:01:29] ERROR

CODE: ER_CON_COUNT_ERROR
MESSAGE: Too many connections

Error: Too many connections
    at Packet.asError (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/packets/packet.js:728:17)
    at ClientHandshake.execute (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/commands/command.js:29:26)
    at Connection.handlePacket (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:481:34)
    at PacketParser.onPacket (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

[2024-05-07 06:01:29] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 1077ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:news","include":"authors,tags","limit":"5","context":{"member":null}}}


[2024-05-07 06:01:29] ERROR

CODE: ER_CON_COUNT_ERROR
MESSAGE: Too many connections

Error: Too many connections
    at Packet.asError (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/packets/packet.js:728:17)
    at ClientHandshake.execute (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/commands/command.js:29:26)
    at Connection.handlePacket (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:481:34)
    at PacketParser.onPacket (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:97:12)
    at PacketParser.executeStart (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/var/www/datasciencedigest/versions/5.82.6/node_modules/mysql2/lib/connection.js:104:25)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

[2024-05-07 06:01:29] WARN

NAME: HelperWarning
CODE: SLOW_GET_HELPER
MESSAGE: {{#get}} helper took 1077ms to complete

level: normal

ERROR DETAILS:
    {"api":"postsPublic.browse","apiOptions":{"filter":"tag:articles","include":"authors,tags","limit":"4","context":{"member":null}}}

For load testing I use https://locust.io/

That is not the same error, though.

In your post from before, you got an actual error because the get-helper aborted:

Right now, you are getting a warning and the get-helper actually only takes a little over one second (which is still way too long, but does not abort the entire operation):

What’s more pressing in my eyes is this

Ghost should not max out the database connections. So, the issue is, in my eyes, still with your database, not Ghost. The question is what causes these connections? Are you using the database for anything apart from Ghost?

No, the database is only used for Ghost, and the instance on which the website is located is also used only for it.
Can you share your configuration for MySQL?

My MySQL configuration won’t help you much, since that’s specific to how I run Ghost :smiley:

I’d rather try to get to the bottom of the problem. Why are there so many connections on the database, where are they from, and what do they do?

Log into your database and run SHOW PROCESSLIST;. That should give you an overview over what’s going on on the database.

Additionally, SHOW VARIABLES LIKE "MAX_CONNECTIONS"; should show you what the max_connections value on your database server is. If that is super low and the processes are all legit, you could increase that.

Since you mentioned that you’re on RDS, could it be a possibility that the resources for the database server simply aren’t enough?

3 Likes