HTTPError.net

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

307 Temporary Redirect

Fault: Neither
TL;DR

Temporary redirect that preserves the request method.

The request should be repeated with another URL, but future requests should still use the original URL.

What HTTP 307 Temporary Redirect Means

The request should be repeated with another URL, but future requests should still use the original URL.

Temporary redirect that preserves the request method.

Common Causes

What Visitors Should Do

Notes for Developers

307 vs 302 vs 301 vs 308

CodePermanent?Method on redirectTypical use
301YesMay change POST to GETMoved pages, domain or HTTPS migrations
302NoMay change POST to GETShort-term moves, login redirects
303NoAlways GETRedirect after a form POST
307NoMust keep method and bodyTemporary moves of APIs or forms
308YesMust keep method and bodyPermanent moves of APIs or forms

RFC 9110 allows clients to switch a POST to GET on a 301 or 302 for historical reasons, which is why 307 and 308 exist.

307 and HSTS

If you see a 307 Internal Redirect in Chrome DevTools when opening an http:// URL, the redirect was made by the browser itself because the site uses HSTS (HTTP Strict Transport Security). No request reached the server; the browser upgraded the URL to HTTPS on its own.

Returning a 307 Temporary Redirect (Code Examples)

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

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(307).json({ error: 'Temporary Redirect' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Temporary Redirect'), 307

PHP

<?php
http_response_code(307);
header('Content-Type: application/json');
echo json_encode(['error' => 'Temporary Redirect']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 307 Temporary Redirect

Frequently Asked Questions

What does HTTP 307 Temporary Redirect mean?

Temporary redirect that preserves the request method. In short: The request should be repeated with another URL, but future requests should still use the original URL.

How should I handle an HTTP 307 Temporary Redirect response?

Use instead of 302 to preserve HTTP method. Set Location header.

Official Specification

The 307 Temporary Redirect status code is defined in RFC 9110 Section 15.4.8.

View the IANA HTTP Status Code Registry →