Skip to content

Proposal to create different pages for 5XX errors #22050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
pcx_content_type: troubleshooting
title: Error 500
source: null
---

## Error 500: internal server error

This error indicates a problem with your origin web server, preventing it from fulfilling the request.

### Common causes

The `Error establishing database connection message` is a common HTTP `500` error, typically indicating an origin web server issue. If you encounter this error, contact your hosting provider for assistance.

### Resolution

When dealing with most `5XX` errors, the first step is to reach out to your hosting provider or site administrator to help troubleshoot the issue. Share the necessary [error details](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to your hosting provider to assist troubleshooting the issue.

However, if the `500` error contains `cloudflare` or `cloudflare-nginx` in the HTML response body, contact [Cloudflare support](/support/contacting-cloudflare-support/) and provide the following details:

- Your domain name
- The time and timezone of the `500` error occurrence
- The output of `www.example.com/cdn-cgi/trace` from the browser where the `500` error was observed (replace `www.example.com` with your actual domain and hostname)

:::note

If you observe blank or white pages when visiting your website, confirm whether the issue occurs when [temporarily pausing Cloudflare](/fundamentals/setup/manage-domains/pause-cloudflare/) and contact your hosting provider for assistance.
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
pcx_content_type: troubleshooting
title: Error 502 or 504
source: null
---

## Error 502 bad gateway or error 504 gateway timeout

An HTTP `502` or `504` error indicates that Cloudflare is unable to establish contact with your origin web server.

### Common causes

There are two possible causes:

- [`502/504` errors from your origin web server](#502504-from-your-origin-web-server) (most common).
- [`502/504` errors from Cloudflare](#502504-from-cloudflare).

You may also see `504` status codes in logs or analytics caused by [cache MISS responses from Early Hints](/cache/advanced-configuration/early-hints/#emit-early-hints).

### Resolution

To resolve `502/504` errors, it is essential to identify whether the issue originates from your origin web server or Cloudflare. In the following sections, you can find more details for troubleshooting and resolving errors from both sources.

#### 502/504 from your origin web server

Cloudflare returns a Cloudflare-branded HTTP `502` or `504` error when your origin web server responds with a standard HTTP `502 bad gateway` or `504 gateway timeout` error:

![Example of a Cloudflare-branded error 502.](~/assets/images/support/image1.png)

Contact your hosting provider to troubleshoot these common causes at your origin web server:

- Ensure the origin server responds to requests for the hostname and domain within the visitor's URL that generated the `502` or `504` error.
- Investigate excessive server loads, crashes, or network failures.
- Identify applications or services that timed out or were blocked.

#### 502/504 from Cloudflare

A `502` or a `504` error originating from Cloudflare appears as follows:

![Example of an unbranded error 502.](~/assets/images/support/image5.png)

If the error does not mention `cloudflare`, contact your hosting provider for assistance. Refer to [502/504 errors from your origin](#502504-from-your-origin-web-server) for more information.

This error can occur due to a compression issue at the origin, such as when the origin server serves gzip-encoded compressed content but fails to update the `content-length` header, or if the origin is serving broken gzip compressed content. To diagnose this, you can try disabling compression at your origin to confirm if it resolves the error.

Additionally, in some cases, a particular data center may experience a sudden increase in traffic. To ensure minimal impact for customers, our automated processes will redirect traffic to another data center. These adjustments typically happen seamlessly and take just a few seconds. However, during this process, some clients may experience temporary latency or HTTP `502` errors. You can find more information about our automated traffic management tools in this [blogpost](https://blog.cloudflare.com/meet-traffic-manager).

If you need further assistance from our Support team, provide the following details to [Cloudflare Support](/support/contacting-cloudflare-support/) to avoid delays in processing your inquiry:

- The time and timezone when the issue occurred.
- The URL that resulted in the HTTP `502` or `504` response (for example, `https://www.example.com/images/icons/image1.png`).
- The output from browsing to `<YOUR_DOMAIN>/cdn-cgi/trace`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
pcx_content_type: troubleshooting
title: Error 503
source: null
---

## Error 503: service temporarily unavailable

HTTP error 503 occurs when your origin web server is overloaded.

### Common causes

There are different causes identifiable by the error message or the location of the error:

- Error does not contain `cloudflare` or `cloudflare-nginx` in the HTML response body. In this case, the issue is likely from your origin server.
- Error contains `cloudflare` or `cloudflare-nginx` in the HTML response body. In this case, the issue may stem from Cloudflare.
- Error is only visible in logs or analytics.

### Resolution

To resolve a `503` error, first determine whether the issue originates from your origin web server or Cloudflare. The following sections provide guidance on troubleshooting both scenarios.

#### 503 Error without `cloudflare` or `cloudflare-nginx`

If the error does not contain `cloudflare` or `cloudflare-nginx` in the HTML response body, contact your hosting provider to verify if they rate limit requests to your origin web server.

#### 503 Error with `cloudflare` or `cloudflare-nginx`

If the error contains `cloudflare` or `cloudflare-nginx` in the HTML response body, a connectivity issue occurred in a Cloudflare data center. Provide [Cloudflare support](/support/contacting-cloudflare-support/) with the following information:

- Your domain name
- The time and timezone of the `503` error occurrence
- The output of `www.example.com/cdn-cgi/trace` from the browser where the `503` error was observed (replace `www.example.com` with your actual domain and hostname)

#### 503 Error only visible in logs and analytics

These errors result from [unsuccessful prefetches from Speed Brain](/speed/optimization/content/speed-brain/#how-speed-brain-works) and can be discarded. These errors are not visible to visitors of your website. [Speed Brain](/speed/optimization/content/speed-brain/#enable-and-disable-speed-brain) can be disabled for the zone if needed (this feature cannot be disabled for a specific path).
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
pcx_content_type: troubleshooting
title: Error 520
source: null
---

## Error 520: web server returns an unknown error

This error occurs when the origin server returns an empty, unknown, or unexpected response to Cloudflare.

### Common causes

This error is often triggered by:

- Origin server crashes or misconfigurations.
- Firewalls or security plugins blocking [Cloudflare IPs](https://www.cloudflare.com/ips) at your origin.
- Headers exceeding 16 KB (often due to excessive cookies).
- Empty or malformed responses lacking an HTTP status code or response body.
- Missing response headers or origin web server not returning [proper HTTP error responses](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml).
- Incorrect HTTP/2 configuration at the origin server.

:::note

`520` errors are prevalent with certain PHP applications that crash the origin web server.

:::

### Resolution

:::note

As a temporary workaround, you can set the affected DNS record to [DNS-only](/dns/proxy-status/) in the Cloudflare **DNS** app or [temporarily pause Cloudflare](/fundamentals/setup/manage-domains/pause-cloudflare/).

:::

- Contact your hosting provider or site administrator and share the necessary [error details](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to assist with troubleshooting. Request a review of your origin web server error logs for crashes and check for [common causes](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-520/#common-causes) mentioned in the previous section.

- If HTTP/2 is enabled at your origin server, ensure it is correctly set up. Cloudflare connects to servers who announce support of HTTP/2 connections via [ALPN](https://blog.cloudflare.com/introducing-http2). If the origin web server accepts the HTTP/2 connection but then does not respect or support the protocol, an HTTP `520` error will be returned. You can disable the [HTTP/2 to Origin](/speed/optimization/protocol/http2-to-origin/#disable-http2-to-origin) in **Speed** > **Optimization** > **Protocol Optimization** on the Cloudflare dashboard.

- If `520` errors continue after contacting your hosting provider or site administrator, provide the following information to [Cloudflare Support](/support/contacting-cloudflare-support/):

- Full URL(s) of the resource requested when the error occurred.
- Cloudflare **cf-ray** from the `520` error message.
- Output from `http://<YOUR_DOMAIN>/cdn-cgi/trace`.
- Two [HAR files](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#generate-a-har-file):
- One with Cloudflare enabled on your website.
- Another with [Cloudflare temporarily disabled](/fundamentals/setup/manage-domains/pause-cloudflare/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
pcx_content_type: troubleshooting
title: Error 521
source: null
---

## Error 521: web server is down

Error `521` occurs when the origin web server refuses connections from Cloudflare. Security solutions at your origin may block legitimate connections from certain [Cloudflare IP addresses](https://www.cloudflare.com/ips).

### Common causes

The two most common causes of `521` errors are:

- Offlined origin web server application.
- Blocked Cloudflare requests.

### Resolution

Contact your hosting provider or site administrator and share the necessary [error details](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to assist in troubleshooting these common causes:

- Ensure your origin web server is responsive.
- Review origin web server error logs to identify web server application crashes or outages.
- Confirm [Cloudflare IP addresses](https://www.cloudflare.com/ips) are not blocked or rate limited.
- Allow all [Cloudflare IP ranges](https://www.cloudflare.com/ips) in your origin web server's firewall or other security software.
- Confirm that — if you have your **SSL/TLS mode** set to **Full** or **Full (Strict**) — your origin supports HTTPS and/or you have installed a [Cloudflare Origin Certificate](/ssl/origin-configuration/origin-ca) or a certificate matching the [requirements for these modes](/ssl/origin-configuration/ssl-modes/#custom-ssltls).
- Find additional troubleshooting information on the [Cloudflare Community](https://community.cloudflare.com/t/community-tip-fixing-error-521-web-server-is-down/42461).
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
pcx_content_type: troubleshooting
title: Error 522
source: null
---

## Error 522: connection timed out

Error `522` occurs when Cloudflare times out contacting the origin web server.

### Common causes

Two different timeouts cause HTTP error `522` depending on when they occur between Cloudflare and the origin web server:

- Before a connection is established, the origin web server does not return a SYN+ACK to Cloudflare within 19 seconds of Cloudflare sending a SYN.
- After a connection is established, the origin web server does not acknowledge (ACK) Cloudflare's resource request within 90 seconds.

### Resolution

- Contact your hosting provider and share the necessary [error details](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to assist in troubleshooting these common causes:

- [Cloudflare IP addresses](https://www.cloudflare.com/ips/) are rate limited or blocked in .htaccess, iptables, or firewalls. Confirm your hosting provider allows Cloudflare IP addresses (most common cause).
- An overloaded or offline origin web server drops incoming requests.
- [Keepalives](http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) are disabled at the origin web server.
- The origin IP address in your Cloudflare **DNS** app does not match the IP address currently provisioned to your origin web server by your hosting provider.
- Packets were dropped at your origin web server.

- If you are using [Cloudflare Pages](/pages/), verify that you have a custom domain set up and that your CNAME record is pointed to your [custom Pages domain](/pages/configuration/custom-domains/#add-a-custom-domain).

- If you are using [Workers with a Custom Domain](/workers/configuration/routing/custom-domains/), performing a `fetch` to its own hostname will cause a `522` error. Consider using a [Route](/workers/configuration/routing/) or target another hostname instead.

- If none of the above leads to a resolution, request the following information from your hosting provider or site administrator before [contacting Cloudflare support](/support/contacting-cloudflare-support/):

- An [MTR or traceroute](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#perform-a-traceroute) from your origin web server to a [Cloudflare IP address](http://www.cloudflare.com/ips) that most commonly connected to your origin web server before the issue occurred. Identify a connecting Cloudflare IP recorded in the origin web server logs.
- Details from the hosting provider's investigation, such as pertinent logs or conversations with the hosting provider.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
pcx_content_type: troubleshooting
title: Error 523
source: null
---

## Error 523: origin is unreachable

This error occurs when Cloudflare cannot contact your origin web server.

### Common causes

This typically occurs when a network device between Cloudflare and the origin web server does not have a route to the origin's IP address.

### Resolution

Contact your hosting provider and share the necessary [error details](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to exclude the following common causes at your origin web server:

- Confirm the correct origin IP address is listed for A or AAAA records within your Cloudflare DNS app.
- Troubleshoot Internet routing issues between your origin and Cloudflare, or with the origin itself.

If none of the above leads to a resolution, request the following information from your hosting provider or site administrator:

- An [MTR or traceroute](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#perform-a-traceroute) from your origin web server to a [Cloudflare IP address](http://www.cloudflare.com/ips) that most commonly connected to your origin web server before the issue occurred. Identify a connecting Cloudflare IP from the logs of the origin web server.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
pcx_content_type: troubleshooting
title: Error 524
source: null
---

## Error 524: a timeout occurred

Error `524` usually indicates that Cloudflare successfully connected to the origin web server, but the origin did not provide an HTTP response before the default 100 seconds [Proxy Read Timeout](/fundamentals/reference/connection-limits/).

### Common causes

This can happen if the origin server is taking too long because it has too much work to do, for example, a large data query, or because the server is struggling for resources and cannot return any data in time.

Error `524` can also indicate that Cloudflare successfully connected to the origin web server to write data, but the write did not complete before the 30 seconds [Proxy Write Timeout](/fundamentals/reference/connection-limits/) (or 6.5 seconds in the case of [Cloudflare Images](/images/)).

:::note

A `524` occurs if the origin web server acknowledges (ACK) the resource request after the connection has been
established, but does not send a timely response.
:::

### Resolution

Here are the options we suggest to work around this issue:

- Implement status polling of large HTTP processes to avoid hitting this error.
- [Contact your hosting provider](/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/#required-error-details-for-hosting-provider) to exclude the following common causes at your origin web server:
- A long-running process on the origin web server.
- An overloaded origin web server.

:::note

Logging request response time at your origin web server helps identify the cause of resource slowness. Contact your hosting provider or site administrator for assistance in adjusting log formats or search for related logging documentation for your brand of web server such as [Apache](http://httpd.apache.org/docs/current/mod/mod_log_config.html) or [Nginx](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format).
:::

- Enterprise customers can increase the `524` timeout up to 6,000 seconds using the [Edit zone setting](/api/resources/zones/subresources/settings/methods/edit/) endpoint (`proxy_read_timeout` setting). If your content can be cached, you may also choose to use a [Cache Rule](/cache/how-to/cache-rules/settings/#proxy-read-timeout-enterprise-only) with the `Proxy Read Timeout` setting selected instead in the Cloudflare Dashboard.

:::note

If the timeouts are on write requests, the [Proxy Write Timeout](/fundamentals/reference/connection-limits/) of 30 seconds cannot be adjusted.
:::

- If you regularly run HTTP requests that take over 100 seconds to complete (for example, large data exports), move those processes behind a subdomain not proxied (grey clouded) in the Cloudflare **DNS** app.

:::note

Note that you may observe a 1 second difference between the timeout you have set and the actual time at which the Error `524` is returned. This is expected, it is due to the current work on implementing our proxy - [Pingora](https://blog.cloudflare.com/how-we-built-pingora-the-proxy-that-connects-cloudflare-to-the-internet/).
As a workaround, you can simply set the timeout to one second more (121 seconds instead of 120 seconds, for example).
:::
Loading
Loading