Error Codes Wiki

HTTP 307 Temporary Redirect — Method-Preserving Redirect

Informational3xx redirection

About HTTP 307 Temporary Redirect

HTTP 307 Temporary Redirect instructs the client to repeat the request at a different URI while preserving the original HTTP method and body. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: 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. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check the Location header in the response for the redirect target. If unexpected 307 loops occur, check HSTS settings and preload list. Clear HSTS cache in browser: chrome://net-internals/#hsts (Chrome). For server config, use 307 instead of 302 when POST body must be preserved. Test with curl -X POST -d 'data' -v -L to verify method preservation. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why do I see 307 redirects to HTTPS?

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

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.