Skip to content

307 Temporary Redirect — Meaning, Common Causes & How to Fix

307 3xx Redirection RFC 9110 §15.4.8

307 Temporary Redirect means: A temporary redirect that guarantees the method and body are preserved when following Location. Unlike 302, a POST stays a POST; it is the safe choice for temporary moves of API endpoints and form targets. Redirection 3xx codes tell the client the resource lives elsewhere, or that a cached copy is still valid. The family splits along two axes: permanent versus temporary, and method-preserving versus method-rewriting. Picking the wrong member causes duplicate submissions, lost POST bodies or stale SEO signals. In practice you will meet 307 when hsts upgrades http to https with a 307 internal redirect in browsers; an api temporarily moves an endpoint and must keep post semantics; a load balancer reroutes a request without altering its method. On the client side, follow Location with the identical method and body; do not convert POST to GET as you might with 302. On the server side, use 307 for temporary moves where method preservation matters; use 308 for the permanent equivalent.

Advertisement
Ad slot · ref-top

When 307 happens

  • HSTS upgrades HTTP to HTTPS with a 307 Internal Redirect in browsers
  • An API temporarily moves an endpoint and must keep POST semantics
  • A load balancer reroutes a request without altering its method

How to fix it

On the client

Follow Location with the identical method and body; do not convert POST to GET as you might with 302.

On the server

Use 307 for temporary moves where method preservation matters; use 308 for the permanent equivalent.

Should you retry?

Follow the redirect (or reuse the cache for 304); update references if permanent.

Debugging steps

When 307 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Inspect the Location header and count redirect hops: chains and loops are the usual culprits, and DevTools shows whether the browser rewrote your method on the way. For this code specifically, check whether the most common trigger applies to your situation: hsts upgrades http to https with a 307 internal redirect in browsers. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

The '307 Internal Redirect' you see in DevTools is generated by the browser itself for HSTS upgrades — no server sent it, and it never appears on the wire.

Examples

Raw HTTP
HTTP/1.1 307 Temporary Redirect
Location: https://example.com/api/v2/resource

curl
curl -i https://api.example.com/v1/resource   # observe the 307 response and its headers
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
// 307 Temporary Redirect: fetch follows redirects automatically.
// Use redirect: "manual" only when you must inspect Location yourself;
// browsers rewrite POST->GET on 301/302 but preserve it on 307/308.
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
# 307 Temporary Redirect: requests follows redirects by default.
# allow_redirects=False to inspect Location; note requests preserves
# the method on 307/308 but rewrites POST->GET on 301/302 like browsers.

Frequently asked questions

Why does Chrome show '307 Internal Redirect'?

That is HSTS at work: the browser itself upgrades http:// to https:// before the request leaves, labeling it 307 Internal Redirect. No server sent it.

307 vs 302 in one sentence?

307 preserves the request method and body; 302 historically allows browsers to rewrite POST to GET.

Which redirect code should I use?

Permanent move: 301 (GET) or 308 (method-preserving). Temporary: 302 (GET) or 307 (method-preserving). After a POST that should not repeat on refresh: 303. Cache revalidation is 304, not a redirect.

Do redirects hurt SEO or performance?

Single-hop permanent redirects (301/308) pass link equity and are fine. Chains, loops and temporary redirects for permanent moves waste crawl budget, add latency and dilute signals.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →