302 Found
The resource is temporarily at a different URL. Clients follow the Location header but keep using the original URL in future.
What 302 Found means
302 is the standard temporary redirect, used for things like sending a logged-out user to a login page. Search engines keep the original URL indexed. In HTTP/1.0 it was called Moved Temporarily.
Browsers historically changed POST to GET when following a 302, and the spec now allows that. The ambiguity is why 303 (always switch to GET) and 307 (never change the method) exist.
Common causes
- Login or session checks that bounce between two URLs, giving ERR_TOO_MANY_REDIRECTS.
- A session cookie that never gets saved, so the app keeps redirecting to the login page.
- A temporary redirect left in place for a permanent move, so search engines keep the old URL.
How to fix 302 Found
- As a visitor stuck in a loop, clear cookies for the site and try again.
- Check the session cookie's Domain, Path and Secure settings, especially behind a proxy that terminates HTTPS.
- If the move is permanent, switch to 301 or 308.
Headers that go with it
Location
Example response
HTTP/1.1 302 Found
Location: https://example.com/new-page
Content-Type: text/plain; charset=utf-8
302 FoundHow to check for a 302 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 === 302) {
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 == 302:
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 == 302 {
fmt.Println(res.Status, res.Header.Get("Location"))
}Specification
302 Found is defined in RFC 9110, section 15.4.3.
Related status codes
- 301
The page has moved to a new URL for good. Browsers and search engines follow the Location header and update their links.
- 303
The server redirects the client to another URL that it must fetch with GET, typically after a form submission or other POST.
- 307
The resource is temporarily at another URL, and the client must repeat the exact same request there, keeping the method and body.