Location HTTP Origin: Network OSI layer 7 · Application Last updated 18 Nov 2026

Redirect goes to the wrong host, port or scheme (bad Location header)

The Location header sends the browser to an internal hostname, localhost, the wrong port or http instead of https.

Exact message you may see redirected to localhostredirect goes to wrong port 8080Location header contains internal hostnameredirects to http instead of httpsredirect to internal IP
Seen on: HTTP Nginx Java

Meaning

Apps behind proxies build absolute redirect URLs from the request they see (internal host, http, port 8080). Fix by passing Host/X-Forwarded-Host/X-Forwarded-Proto, setting the public base URL, or returning relative Location values.

Common causes

  • App builds URLs from the internal host
  • Proxy not forwarding Host/X-Forwarded-*
  • Base URL/APP_URL misconfigured
  • nginx proxy_redirect missing
  • Port 8080 leaking into the URL

⚡ Quick fix

  1. Set the app's public base URL (APP_URL, SITE_URL)
  2. Forward Host and X-Forwarded-Proto
  3. Use proxy_redirect or relative Location headers

Detailed fix by platform

Nginx

  1. nginx
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect http://backend:8080/ /;

How to diagnose

  1. Location — Internal host?
  2. Forwarded headers — Passed?
  3. Base URL — Correct?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

203 — HTTP 203 Non-Authoritative Information (HTTP)203301 — HTTP 301 Moved Permanently (HTTP)301301/302 — POST request turns into GET after a redirect (body lost) (HTTP)301/302401 — 401 because the Authorization header is stripped (HTTP)401598 — HTTP 598 Network Read Timeout Error (HTTP)598CORS — CORS: Redirect is not allowed for a preflight request (HTTP)CORSERR_TOO_MANY_REDIRECTS (WordPress) — WordPress: ERR_TOO_MANY_REDIRECTS / redirected you too many times on wp-admin or the whole site (WordPress)ERR_TOO_MANY_REDIRECT…Location — 201 Created without a Location header (clients can't find the new resource) (HTTP)LocationLocation

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.