Possibility to change the 502 Bad Gateway Screen

I have changed the 400, 401, 403, 404, 503 Error Screens except for one the Error 502 (because there is no option to change it). I wanted it to be branded to my small website or atleast give some details to the site visitor (like what I did to the other error codes, like how to fix the issue or what to do). The current Error 502 does not show anything but just the Hosting Operating System and 502 Bad Gateway. Anyone knows how to do it? Please help me. If there is an option to change the Error 502 please let me know.

More Background (Not part of the question, Please Ignore this part but may help)
*Errors 400, 401, 403 and 503 are handled by Infinity Free.
*Error 404 was handled by WordPress/WooCommerce and never handled by Infinity Free.
*Error 503 was handled by both Infinity Free and WordPress. Infinity Free handles the Server error part. While, the database Error was handled by WordPress, the two presents 503.
*Now, Error 502 is I guess handled by Infinity Free? Since it presents the NGIX Hosting Operating System.

(EDIT) Is it also possible to change the Error 504 Error Screen?

502 is generally not handled by Apache here, so there’s no way to change the Nginx one.
But you can do this in your .htaccess to set any error you’d like:

ErrorDocument 502 /502.html

And then replace 502 with any error code you want (between 400 and 599), and /502.html with any path to the document describing the error.


Meaning if I created a custom page for 502 and it uses NGIX, meaning my page for 502, 500 and 504 will not appear?

Correct, except for the 500, that is normally handled by Apache.


Something like this:

While you can set custom pages for every 400 and 500 errors, the ones listed above are the most common.

Also, due to server restrictions here, you cannot use a folder called errors, I would recommend calling it error instead.


The 502 error is caused by NGINX, which runs in front of the regular Apache server which runs your website code. NGINX doesn’t use .htaccess files, so it’s not possible to use custom error messages.

The 502 error is generated by NGINX saying that an error occurred while passing on the request to Apache. So I think this is why it’s not possible to generate the error with Apache instead.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.