"Cannot set headers" - Site only loads properly on third refresh

Hello,

I am self-hosting Ghost using Docker on a RaspberryPi 4. You can check it out here: www.roberttera.com

Using nginx and duckdns, and docker is getting the latest ghost version on every restart.

My problem is pretty straighforward yet I don’t seem to find any information about it: if the page is not requested for a few hours, for the first time it is it does not load properly, and I get the following error in the container log (on the left, and on the right you can see how only the HTML loads for the site):

So the error is:
Unhandled rejection Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

So I don’t understand how to even begin fixing this, since it is inside the belly of the container as you can see.

Then, after a refresh, I get the classic “We’ll be right back.” message.

And then, on the third refresh, usually it loads properly.

Any help would be greatly appreciated and thank you in advance! Let me know what additional information you need.

RT