Skip to content

307 Temporary Redirect

The resource is temporarily at another URL, and the client must repeat the exact same request there, keeping the method and body.

What 307 Temporary Redirect means

307 is like 302 with one firm rule: the method and body do not change. A POST stays a POST, which makes it safe for redirecting API calls and form submissions.

In Chrome's network tab you may see "307 Internal Redirect" when a site uses HSTS. The browser upgrades http:// to https:// itself without contacting the server.

For a permanent move with the same method guarantee, use 308.

Headers that go with it

  • Location

Example response

HTTP/1.1 307 Temporary Redirect
Location: https://example.com/new-page
Content-Type: text/plain; charset=utf-8

307 Temporary Redirect

How to check for a 307 response

cURL

# Print only the status code (no -L, so the redirect isn't followed)
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

JavaScript (Node.js)

const res = await fetch("https://example.com/", { redirect: "manual" });
if (res.status === 307) {
  console.log(res.status, res.statusText, res.headers.get("location"));
}

Python

import requests

res = requests.get("https://example.com/", allow_redirects=False)
if res.status_code == 307:
    print(res.status_code, res.reason, res.headers.get("Location"))

Go

client := &http.Client{
	CheckRedirect: func(*http.Request, []*http.Request) error {
		return http.ErrUseLastResponse
	},
}
res, err := client.Get("https://example.com/")
if err != nil {
	log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 307 {
	fmt.Println(res.Status, res.Header.Get("Location"))
}

Specification

307 Temporary Redirect is defined in RFC 9110, section 15.4.8.

  • 302

    Found

    The resource is temporarily at a different URL. Clients follow the Location header but keep using the original URL in future.

  • 308

    Permanent Redirect

    The resource has moved permanently to a new URL, and clients must keep the same method and body when following the redirect.

  • 303

    See Other

    The server redirects the client to another URL that it must fetch with GET, typically after a form submission or other POST.

← all 63 HTTP status codes

Type to search posts, tools and projects.

Keyboard shortcuts

Search+Kor/
Go to homegthenh
Go to bloggthenb
Go to projectsgthenp
Go to timelinegthent
Show this help?
Close search or helpesc