Question

How set up a maintenance page when droplet is off, restarting or not responding to a specific port?

Consider the following: I have a Droplet currently working and configured, with a domain pointing to it, serving something from some port (for e.g. nginx serving a website on 80/443, or a mySQL on 3306).

I’d like to configure for the domain a 503 (Service Unavailable) page when Droplet is currently Turned off, is in a process (for e.g. restarting, re-scaling) or when it’s not serving something on said port (for e.g, Droplet is on but mysql or nginx daemons are off because either crashed or I’m currently giving maintenance).

How can I serve said HTTP response on each of these cases? This is a lot better than simply having the domain give dns/timeout error.

Thank you.

This question from 2014 asks the same thing, but the response given totally hit the mark, like the person didn’t even try to read the question and just blindly answered the inner questions, which were suppositions/thoughts.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 26, 2020
Accepted Answer

Hi there @RaphaelDDL,

As the Droplet would be down, you would need another service in front of the actual Droplet that would be able to serve a maintenance page for example.

There are a couple of things that I could suggest:

  • You could use HAProxy, that way you would point your Domain name to the HAProxy server and it would proxy the traffic to your Droplet, if the Droplet goes down, HAProxy would not be able to connect anymore and it would throw a 503 error. You would be able to change that error with a more meaningful message, you can take a look at this answer here on how to do that:

https://www.digitalocean.com/community/questions/haproxy-change-503-page-with-a-custom

If you decide to go with that option, you could take a look at this introduction tutorial here:

https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts

If you are not familiar with HAProxy, you could achieve the same setup with Nginx as well.

  • Another option would be to use a CDN like Cloudflare, there is a page that Cloudflare shows when the backend Droplet is down and, on the Pro plan and above, is customizable:

http://cloudflarepreview.com/preview-cpage?act=preview&target=cf-error%3A500s

Hope that this helps! Let me know if you have any questions. Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel