# Custom forced 503 page does not work

**URL:** <https://www.ruby-forum.com/t/custom-forced-503-page-does-not-work/235950>\
**Category:** NGINX\
**Created:** [July 25, 2013, 3:06pm UTC](https://www.ruby-forum.com/t/custom-forced-503-page-does-not-work/235950 "2013-07-25T15:06:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 25, 2013, 3:06pm UTC](https://www.ruby-forum.com/t/custom-forced-503-page-does-not-work/235950/1 "2013-07-25T15:06:04Z")

</div>

Hi,  
I’m trying to deliver a custom 503 page for all requests the server  
receives but with the following config it doesn’t work.

server {  
listen 81;  
server\_name localhost;  
error\_log /var/log/nginx/error.log debug;

```
 root /usr/share/nginx/html;

 location / {

```

return 503;  
}

```
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
     root /usr/share/nginx/html;
 }

```

}

I get a 503 response but the 50x.html page is not used even though it is  
present in /usr/share/nginx/html/50x.html. I see no error in the error  
log even in debug mode.  
What is wrong with this config?

Regards,  
Dennis

---

<div class="post-metadata">

**Author:** ![Dennis\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@Dennis\_J](https://www.ruby-forum.com/u/Dennis_J)\
**Post date:** [July 31, 2013, 8:52am UTC](https://www.ruby-forum.com/t/custom-forced-503-page-does-not-work/235950/2 "2013-07-31T08:52:31Z")

</div>

Hi,

Nginx reads from top to bottom, just like you. In your example, you are  
returning 503 (an action) before instructing to use your custom error  
page.  
Just need to put your instructions first, then your actions…like so:

error\_page 500 502 503 504 /50x.html;  
location = /50x.html { root /usr/share/nginx/html; }

location / { return 503; }

-Skyler

Posted at Nginx Forum:

> **[Re: Custom forced 503 page does not work](https://forum.nginx.org/read.php?2,241261,241401#msg-241401)**
>
> Hi, I'm trying to deliver a custom 503 page for all requests the server receives but with the following config it doesn't work. server { listen 81; server\_name localhost; error\_log /var/log/nginx/error.log debug; roo

---

<div class="post-metadata">

**Author:** ![Dennis\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@Dennis\_J](https://www.ruby-forum.com/u/Dennis_J)\
**Post date:** [July 31, 2013, 10:18am UTC](https://www.ruby-forum.com/t/custom-forced-503-page-does-not-work/235950/3 "2013-07-31T10:18:25Z")

</div>

Hello!

On Wed, Jul 31, 2013 at 02:51:43AM -0400, skchopperguy wrote:

> Hi,
> 
> Nginx reads from top to bottom, just like you. In your example, you are  
> returning 503 (an action) before instructing to use your custom error page.  
> Just need to put your instructions first, then your actions…like so:
> 
> error\_page 500 502 503 504 /50x.html;  
> location = /50x.html { root /usr/share/nginx/html; }
> 
> location / { return 503; }

No, config directives order doesn’t matter in general. There are  
some exceptions (like rewrite module directives order, or order of  
locations with regular expressions), but the configuration in  
question is fine and has no problems with directives order.

Most likely, the problem was somewhere else (e.g. conflicting  
server{} block in the configuration, or original message author  
just forgot to reload the configuration after changes).

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**
