Error Codes Wiki

HTTP 307 Temporary Redirect — Method-Preserving Redirect

Informational3xx redirection

Overview

HTTP 307 Temporary Redirect instructs the client to repeat the request at a different URI while preserving the original HTTP method and body.

Key Details

  • 307 guarantees the HTTP method and body are not changed during redirect
  • A POST request redirected with 307 will be resubmitted as POST to the new URL
  • Introduced to fix ambiguity in 302 where browsers changed POST to GET
  • HSTS (HTTP Strict Transport Security) uses 307 internally to redirect HTTP to HTTPS
  • The redirect is temporary — clients should continue using the original URL

Common Causes

  • HSTS enforcement redirecting HTTP to HTTPS internally in the browser
  • Load balancer temporarily routing traffic to a different backend
  • API gateway redirecting requests while preserving method and body
  • Server maintenance requiring temporary rerouting without method change

Steps

  1. 1Check the Location header in the response for the redirect target
  2. 2If unexpected 307 loops occur, check HSTS settings and preload list
  3. 3Clear HSTS cache in browser: chrome://net-internals/#hsts (Chrome)
  4. 4For server config, use 307 instead of 302 when POST body must be preserved
  5. 5Test with curl -X POST -d 'data' -v -L to verify method preservation

Tags

http307temporary-redirecthstsmethod-preserving

More in 3xx Redirection

Frequently Asked Questions

HSTS forces browsers to internally redirect HTTP to HTTPS using 307, ensuring the request method is preserved.