1-Click Droplet for Ghost - working, but frequent 502 Bad Gateway errors

Posted February 4, 2021 482 views


I successfully set up the 1-Click droplet for Ghost. It runs fine, Ghost Doctor doesn’t show any errors. However, the site goes down every few days and shows a 502 Bad Gateway error. As soon as I restart Ghost in the console it starts working again. I doubt it has anything to do with memory as content and traffic is still low/limited.
I use Cloudflare for DNS/CDN. Ghost log -f only shows a “cookie members ssr not found” warning, which doesn’t seem to be the issue. sudo nginx -t says “ok” and “successful”.

Can someone please help or point me in the correct direction? Thanks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Edit: Log shows the following errors (see picture, couldn’t copy any text from the console):

Hi there @apoeschl,

It looks like that your Ghost service might be crashing, how much RAM do you have on your Droplet?

I could suggest checking your system logs and possibly adding a little bit more RAM and a SWAP file:

Let me know how it goes.

by Justin Ellingwood
One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. <$>[warning] [label...
  • I have this exact thing happen to me. Every week or so my ghost will crash with 502 and I’ll have to restart it. I’ve added a 4GB swap file and it still happens. No idea why.

    Nginx logs are filled with

    upstream prematurely closed connection while reading response header

    Like OP, this is with the default Ghost 1-click droplet

    • Yeah, it probably has nothing to do with Ram. There’s hardly any support available, so I’m about to migrate.

      • Hi there,

        The 502 error means that the Nginx service is unable to connect to the backend service, which in your case is Ghost.

        This means that the problem is not with Nginx, but the backend service being unavailable.

        The most common cause for a service to crash is when the server runs out of memory, of course, to verify if this is the case, you need to check your system logs at /var/log/syslog.

        The Nginx error log would not give you much information, but you could check the logs of the Ghost service itself:

        sudo -i -u ghost-mgr
        cd /var/www/ghost
        ghost log