Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To customize an HAProxy-generated 503 response, put a complete HTTP response in a file, map status 503 to that file in a named http-errors section, and attach the section to the frontend (or another proxy section) with errorfiles. Validate the configuration and reload HAProxy after every file change; HAProxy reads error files into memory during configuration load.

http-errors myerrors
    errorfile 503 /etc/haproxy/errorfiles/503.http

frontend www
    bind :80
    default_backend webservers
    errorfiles myerrors

This method applies to the documented HAProxy 2.1-and-newer configuration model. Check the manual for the exact HAProxy release installed on your server because directive availability and supported status codes can differ between releases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a custom HAProxy 503 page changes

HTTP status 503 means that a service is temporarily unable to handle a request. HAProxy can generate that status itself, for example when a backend has no available servers, or it can forward a 503 that an application server produced. The errorfile mapping handles the first case. It does not automatically replace a response body sent by a backend application.

A custom error file is not just an HTML fragment. HAProxy expects the entire HTTP response: status line, headers, a blank line, and the body. Because HAProxy parses and stores that response while loading its configuration, changing the file on disk does not change responses from an already-running process until you reload it.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

Prerequisites and version boundaries

  • Use an HAProxy release that supports the http-errors, errorfile, and errorfiles directives. The official tutorial documents this approach for HAProxy 2.1 and newer, including corresponding Enterprise and ALOHA versions.
  • The HAProxy process must be able to read the response file and every directory in its path.
  • Use an absolute file path. HAProxy’s manual recommends the .http suffix for files containing complete responses.
  • The response must fit the configured response buffer and pass HAProxy’s configuration validation. Malformed or oversized responses can prevent validation or fail when served.
  • You need a safe way to validate and reload the service. The exact reload command depends on your operating system, package, service manager, and HAProxy deployment.

Minimal configuration

Add a named error group and connect it to the frontend that should serve the custom response:

http-errors myerrors
    errorfile 503 /etc/haproxy/errorfiles/503.http

frontend www
    bind :80
    default_backend webservers
    errorfiles myerrors

The group name, frontend name, and paths are arbitrary. What matters is the relationship: errorfile 503 maps the status to a file, and errorfiles myerrors tells the proxy section which named group to use. If several frontends need the same page, they can reference the same named group instead of duplicating the mapping.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the complete 503 response file

Create the directory and file used by the configuration:

sudo install -d -m 0755 /etc/haproxy/errorfiles
sudo editor /etc/haproxy/errorfiles/503.http

Save a complete response such as:

HTTP/1.1 503 Service Unavailable
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Temporarily unavailable</title></head>
<body>
  <h1>Service temporarily unavailable</h1>
  <p>Please try again shortly.</p>
</body>
</html>

Status line

The first line must identify the HTTP version, status code, and reason phrase. For this page, use HTTP/1.1 503 Service Unavailable. The status code in the file should match the status mapped by errorfile.

Headers and the separating blank line

Put each header on its own line. The blank line after the headers is required; it marks the start of the body. Content-Type: text/html; charset=utf-8 tells clients how to interpret the markup. Cache-Control: no-cache helps avoid retaining a temporary outage page in intermediaries. Add other headers only when you understand their effect on your clients and caches.

Body markup

Keep the HTML self-contained. A simple message, an incident reference, and instructions to retry are usually more useful than a large page that depends on the unavailable application. Do not place secrets, internal hostnames, stack traces, or debugging output in this response.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Permissions

Ensure the account running HAProxy can traverse the directory and read the file. A file that is readable by the administrator but not by the HAProxy process will cause validation or reload failures. Set ownership and mode according to your distribution’s service account and your security policy rather than copying a universal ownership command.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Apply and verify the change safely

  1. Create the directory and response. Put 503.http at the absolute path named in errorfile 503. Confirm that the file contains a status line, headers, a blank line, and HTML.
  2. Attach the group to the emitting proxy section. Add errorfiles myerrors to the frontend, backend, or other section that can generate the 503. A group defined in the global configuration does nothing until it is referenced.
  3. Validate the complete configuration. Run the parser for the installed HAProxy version, for example:
    haproxy -c -f /etc/haproxy/haproxy.cfg

    Use the configuration path and executable location used by your installation. Fix every reported path, permission, syntax, or response-format error before reloading.

  4. Reload HAProxy. Use your service manager’s normal, graceful reload procedure. There is no single command that is correct for every package layout. A reload is required because HAProxy reads and stores custom error files in memory at the same time that it reads the configuration.
  5. Trigger a controlled HAProxy-generated 503. Test a maintenance frontend or a backend with no available servers, rather than taking a production service offline unexpectedly. Send a request to the listener and inspect the HTTP status, headers, and body.
  6. Confirm the response source. Verify that the 503 was generated by HAProxy. If an application server returned it, the local errorfile mapping will not replace that response unless you add an explicit interception rule.

Why an edited page does not appear until reload

HAProxy does not continually reread an error file for each request. It parses the file and keeps its contents in memory when loading the configuration. Editing /etc/haproxy/errorfiles/503.http while the process is running therefore leaves the old response active.

If a new page is not visible after editing, check the operational sequence:

  • Confirm that you edited the exact absolute path used by errorfile 503.
  • Run configuration validation again and read the complete error output.
  • Check that the reload actually completed and that the new process is serving the listener.
  • Send a request that reaches the HAProxy-generated error path, not a backend that returns its own 503.
  • Inspect headers and body with a command-line client or browser developer tools. A cached intermediary or browser can make an old page appear even after HAProxy has changed.

HAProxy-generated versus backend-generated 503 responses

HAProxy-generated 503

When HAProxy cannot select or connect to an available backend server, it creates the response. The errorfile 503 entry in the selected http-errors group supplies the status response in this situation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Backend-generated 503

If a reachable application returns status 503, HAProxy normally forwards that response, including its body and headers. To replace it, add a response rule that deliberately returns the selected error-file response when the status sample is 503:

http-errors myerrors
    errorfile 503 /etc/haproxy/errorfiles/503.http

frontend www
    bind :80
    default_backend webservers
    errorfiles myerrors
    http-response return status 503 default-errorfiles if { status 503 }

This pattern uses default-errorfiles for the return rule. Choose the error-file group deliberately if your configuration has several groups. The rule replaces the backend’s response body and headers for matching responses, so it can remove application-specific headers, retry information, or diagnostic details. Apply it only when a uniform proxy-level page is the intended behavior.

Serving a redirect instead of a local file

For a HAProxy-generated 503, errorloc 503 <url> redirects the client to another location instead of serving the local response file. The manual documents 302 behavior for errorloc and errorloc302, and 303 behavior for errorloc303. A 303 instructs the client to fetch the destination with GET, which is generally safer when the original request used a method such as POST.

Use a destination that remains available during the outage. A relative URL that routes back through the same failing frontend can create a redirect loop. Redirect directives in this context do not rewrite a 503 that originated in a backend application; intercept backend responses explicitly if that is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Static files versus dynamic error templates

A static errorfile is appropriate when every request can use the same response. HAProxy’s http-error facility also supports lf-file and lf-string forms for content rendered with sample-fetch expressions. These forms are useful when the response needs values that HAProxy can evaluate, such as request or connection data.

http-errors dynamic
    http-error status 503 content-type "text/html; charset=utf-8" lf-file /etc/haproxy/errorfiles/503.lf

In a template, lf-file renders the file as a log-format expression, while the file form serves raw content. Set content-type when returning a template directly so clients receive an explicit media type. Keep dynamic expressions limited to data that is safe to expose, and validate the resulting response just as you would a static file.

Understanding scope and reuse

The named http-errors block is a reusable mapping, not a response that is active everywhere automatically. A frontend, backend, or other proxy section must select it with errorfiles. This separation lets one listener use a branded maintenance page while another uses a plain response, and it lets multiple listeners share one centrally maintained file.

Reuse also means that one file change can affect every section referencing the group after the next reload. Review those consumers before changing wording, links, or headers. If different audiences need different responses, define separate named groups and attach each one explicitly rather than relying on an implicit default.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Header and method decisions

The response file controls the headers HAProxy sends with its locally generated error. Keep the status line at 503 even if the body contains a more detailed explanation; clients, monitoring systems, and automated retry logic use the status code. A short Cache-Control: no-cache header is appropriate for a temporary outage page in the example, while additional cache, security, or policy headers should be added only after checking their effect on all clients.

Redirect choice is especially important for non-GET requests. A 302 may be interpreted differently by clients, whereas the documented 303 form tells the client to retrieve the destination with GET. If the destination is unavailable or points back to the failing listener, users can see a loop instead of a useful outage message.

Testing the right failure path

A successful test must exercise the source of the response you intend to customize. A backend that is reachable but returns its own 503 tests forwarding behavior, not the errorfile mapping. Conversely, disabling all servers in a controlled test backend exercises HAProxy’s locally generated 503 path.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Record the returned status, every relevant header, and the body. Check that the body is the newly loaded version, that the content type is present, and that the response is not coming from a cache or an upstream application. Repeat the check after a reload and after any change to the named group, file path, or frontend attachment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing the implementation

Situation Recommended mechanism Important behavior
HAProxy has no usable backend server http-errors with errorfile 503 Serves a complete local response for a proxy-generated 503.
The same static page is needed by several frontends One named error group referenced with errorfiles Centralizes the mapping; every referencing section uses the same loaded file.
An application 503 must have a uniform proxy page http-response return status 503 conditioned on { status 503 } Replaces the backend body and headers; use intentionally.
Clients should fetch a maintenance page elsewhere errorloc or errorloc303 Redirects HAProxy-generated errors; avoid destinations that can fail or loop.
Content needs HAProxy-evaluated values http-error with lf-file or lf-string Renders log-format expressions; specify a content type for direct template responses.

Operational limits and failure modes

Unsupported directive or status

Directive names and supported customizable status codes vary by release. If validation reports an unknown directive or unsupported status, consult the manual for the exact deployed version rather than assuming that a configuration from another release is compatible.

Unreadable file

Check directory traversal permissions, file ownership, and the account used by the service. Test access as that account where your operating system permits it.

Malformed response

Look for a missing status line, invalid header syntax, an absent blank line, or accidental binary content. Keep the file as a plain-text HTTP response and validate after each edit.

Response too large

Error responses are kept in memory and must fit the configured response buffer. A large image-heavy page or oversized headers can fail validation or serving. Prefer a compact, self-contained outage page and link to external assets only when those assets are guaranteed to remain available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reload interruption

Always validate before reloading and use the graceful procedure supplied by your service manager. If validation fails, the running process should remain in place; investigate the reported line, path, and permissions before attempting another reload.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Designing a useful outage page

  • State that the service is temporarily unavailable without blaming the user.
  • Give a retry instruction and, where appropriate, an expected recovery channel such as a status page or support route.
  • Keep the page usable on small screens and without JavaScript.
  • Do not promise a recovery time that your operations team has not established.
  • Use the same language and accessibility practices as the rest of the service, but keep dependencies out of the critical path.

Validation checklist

  • The file uses an absolute path and contains the full HTTP response.
  • The status line is HTTP/1.1 503 Service Unavailable and the headers are followed by one blank line.
  • The HAProxy process can read the file and traverse its parent directories.
  • The named http-errors group is attached with errorfiles to the section that emits the error.
  • The configuration parser completes successfully.
  • HAProxy has been reloaded since the last file edit.
  • The test request reaches a HAProxy-generated 503, or an explicit interception rule is present for backend-generated 503 responses.
  • The returned status, headers, and body are all the values intended for clients.

Frequently Asked Questions

Why does my edited 503 page not appear immediately?

HAProxy reads and stores custom error files in memory when it loads the configuration. Edit the exact absolute path, validate the configuration, perform a successful reload, and then test a request that reaches an HAProxy-generated 503.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Does errorfile replace a 503 returned by my application?

No. The mapping is used for errors HAProxy generates itself. A reachable backend’s 503 is normally forwarded unchanged. Use an explicit http-response return status 503 ... if { status 503 } rule when you intentionally want to replace backend responses.

What must be inside a 503 error file?

Include the complete HTTP response: a status line such as HTTP/1.1 503 Service Unavailable, headers, one blank line, and the body. An HTML fragment by itself is not sufficient.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where should I attach errorfiles?

Attach the named group to the frontend, backend, or other proxy section that can emit the error. Defining an http-errors group without selecting it does not activate the mapping.

Can I redirect users to a maintenance page instead?

For HAProxy-generated errors, errorloc and errorloc302 document 302 redirects, while errorloc303 documents a 303 redirect. A 303 makes the client fetch the destination with GET, which is safer for non-GET requests. Keep the destination available and avoid a URL that routes back into the failing path.

Can the error page include dynamic HAProxy values?

Yes. The http-error facility supports lf-file and lf-string forms that render sample-fetch expressions. Set an explicit content type for a template response and expose only data that is safe for clients.

Why does validation fail even though the HTML looks correct?

Check the absolute path, directory traversal permissions, the HAProxy service account, the status line, header syntax, the required blank line, and the response size. Error responses are loaded at configuration time and must fit the configured response buffer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which HAProxy versions support this configuration pattern?

The documented http-errors, errorfile, and errorfiles approach applies to HAProxy 2.1 and newer, with corresponding Enterprise and ALOHA versions. Verify directive names and supported status codes against the manual for the installed release.

The Bottom Line

Use a named http-errors group, map 503 to an absolute-path file containing the full HTTP response, attach it with errorfiles, validate, and reload. Test the HAProxy-generated failure path separately from backend-generated 503 responses; choose interception, redirection, or dynamic templates only when their replacement behavior is deliberate.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.