Amit Jotwani

Amit Jotwani

Resolving a 504 Timeout Error on Ghost with Digital Ocean

Tinkering

Woke up to a 504 error this morning. It's hosted on Digital Ocean, so I reached out to support, which wasn't very helpful. They basically said this, and then dumped a bunch of not-very-helpful-generic-504-articles.

As a self-managed infrastructure as a service (IaaS) provider, we do not have access to your servers so I cannot see your environment. The answer will depend on your webserver and/or database configuration. The system and application error and access logs may include additional details that could provide more insight on this.

I hadn't changed anything on my website, so I knew it probably had nothing to do with webserver/database configurations. Nothing had changed as far as I knew. A lot of the articles pointed me to the console. I couldn't even access the console through digital ocean dashboard though. It threw an error of - "Timed out while waiting for handshake".

I then ran into this post (How to restart your Ghost site on Digital Ocean) from Dan Rowden. That gave me a hint that I should look into forcefully restarting my Ghost site. Another quick google search, and I ran into this post - 2 Ways To Reboot a Droplet on DigitalOcean.

Restarting a Droplet on Digital Ocean

To summarize - There are two ways to reboot a Droplet on DigitalOcean, these are:

  1. Gracefully: Similar to that of restarting your machine through the Restart or Shut Down commands.
  2. Forcefully: Similar to holding down the power button on your machine and then powering it back on again.

The graceful way wasn't working out in this case, since I couldn't even access the console. So, I went the forceful way.

  1. Visit the Power tab in the Droplet.
  2. Click the Power Cycle button in the Power Cycle section
  3. Wait for confirmation message and wait a few minutes for the Droplet to reboot.

That fixed it. I could access the console, and the website came right back up.

So why did this happen?

During my troubleshooting, I came across this post on Digital Ocean community, pointing to memory issues being one of the causes for a 504 errors.

This reminded me that I was trying to upload a large size image (>6MB) to my Ghost site yesterday. That was taking forever to load, and timed out each time I tried it. I now wonder if that process consumed most of the RAM, and the server essentially ran out of memory. Rebooting the server must have reset the memory. That makes sense to me. I will go with that argument, and vow never to upload a 6MB PNG to my Ghost site!