HTTPError.net

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

504 Gateway Timeout

Fault: Server
TL;DR

Gateway/proxy timeout waiting for upstream server.

The server did not receive a timely response from the upstream server.

What HTTP 504 Gateway Timeout Means

The server did not receive a timely response from the upstream server.

Gateway/proxy timeout waiting for upstream server.

Common Causes

How to Fix It (For Visitors)

How to Fix It (For Developers/Admins)

Returning a 504 Gateway Timeout (Code Examples)

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

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(504).json({ error: 'Gateway Timeout' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Gateway Timeout'), 504

PHP

<?php
http_response_code(504);
header('Content-Type: application/json');
echo json_encode(['error' => 'Gateway Timeout']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 504 Gateway Timeout

Frequently Asked Questions

What does HTTP 504 Gateway Timeout mean?

Gateway/proxy timeout waiting for upstream server. In short: The server did not receive a timely response from the upstream server.

Is a 504 Gateway Timeout error my fault or the website's?

504 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 504 Gateway Timeout error?

Increase gateway timeout (proxy_read_timeout). Optimize slow database queries. Add indexes to database.

Official Specification

The 504 Gateway Timeout status code is defined in RFC 7231 Section 6.6.5.

View the IANA HTTP Status Code Registry →