502 Bad Gateway shows each couple of weeks and requires a manual reboot

March 9, 2015 2.1k views
Ghost Nginx Node.js

For the last 6 months I've been running Ghost with Node.js here on DigitalOcean. As I'm not very good with all the technical server related topics I always use the forum to find most of the questions and problems that I have. Nevertheless something has been happening each 2 weeks or so with my Ghost blog. It works perfectly fine for a couple of weeks and then it shows:

<^>502 Bad Gateway

nginx/1.4.6 (Ubuntu)
<^>

I then have to manually go to console access and type then the service ghost-XXXX restart to get it back to normal. Is there anyway to change this or to create each week create an automatic action to run this code at least so I don't have to do it manually?

2 comments
  • The most common reason for services to suddenly stop on a droplet (especially a small one) is those services running out of available memory. I would recommend setting up a swap file which should resolve this issue and seeing if the 502 errors you have been encountering continue. This tutorial will guide you in the process.

    by Justin Ellingwood
    Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
  • Thanks ryanpq! I followed the guide and will keep the post updated in case it works.

1 Answer

This question was answered by @ryanpq:

The most common reason for services to suddenly stop on a droplet (especially a small one) is those services running out of available memory. I would recommend setting up a swap file which should resolve this issue and seeing if the 502 errors you have been encountering continue. This tutorial will guide you in the process.

View the original comment

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.
Have another answer? Share your knowledge.