HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

522 Connection Timed Out

Fault: Server
TL;DR

A Cloudflare-specific code: the origin did not complete the TCP handshake within the allowed time.

Cloudflare timed out trying to establish a TCP connection to the origin.

What HTTP 522 Connection Timed Out Means

Cloudflare timed out trying to establish a TCP connection to the origin.

A Cloudflare-specific code: the origin did not complete the TCP handshake within the allowed time.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 522 Connection Timed Out (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 522 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(522).json({ error: 'Connection Timed Out' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Connection Timed Out'), 522

PHP

<?php
http_response_code(522);
header('Content-Type: application/json');
echo json_encode(['error' => 'Connection Timed Out']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 522 Connection Timed Out

Frequently Asked Questions

What does HTTP 522 Connection Timed Out mean?

A Cloudflare-specific code: the origin did not complete the TCP handshake within the allowed time. In short: Cloudflare timed out trying to establish a TCP connection to the origin.

Is a 522 Connection Timed Out error my fault or the website's?

522 is a 5xx server-error code, so the problem is on the server side, not your browser or device. As a visitor you can usually only retry; if you run the site, investigate the server.

How do I fix a 522 Connection Timed Out error?

Allow Cloudflare IPs and stop dropping packets. Reduce origin load / scale up. Increase keepalive timeout on the origin.

Official Specification

The 522 Connection Timed Out status code is defined in Cloudflare (non-standard).

View the IANA HTTP Status Code Registry →