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

Browser keeps asking for username and password (Basic auth prompt loop)

The login dialog reappears after entering credentials, because the server keeps answering 401.

Exact message you may see basic auth prompt keeps reappearingpassword prompt loop 401user not found htpasswdpassword mismatch htpasswdAuthUserFile not found
Seen on: HTTP Apache Nginx

Meaning

Wrong credentials, a different realm or password file, .htpasswd unreadable by the web server, or the Authorization header being stripped by a proxy all cause the loop. Check the error log for "user not found" or "password mismatch", the AuthUserFile path and permissions, and that the header reaches the app.

Common causes

  • Wrong username or password
  • .htpasswd missing or unreadable by the web server user
  • Wrong AuthUserFile path
  • Authorization header stripped by a proxy
  • Password hash type unsupported (bcrypt/apr1 mismatch)

⚡ Quick fix

  1. Check the server error log for the exact reason
  2. Recreate the entry: htpasswd -B /etc/nginx/.htpasswd user
  3. Fix permissions so the web server can read the file

Detailed fix by platform

Linux

  1. bash
    sudo htpasswd -B -c /etc/nginx/.htpasswd admin
    sudo chmod 640 /etc/nginx/.htpasswd && sudo chown root:www-data /etc/nginx/.htpasswd

How to diagnose

  1. Error log — Which reason?
  2. htpasswd — Readable?
  3. Header — Reaches the app?

🔧 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):

102 — HTTP 102 Processing (HTTP)102201 — HTTP 201 Created (HTTP)201202 — HTTP 202 Accepted (HTTP)202401 — HTTP 401 Unauthorized (HTTP)401401 — 401 Unauthorized without WWW-Authenticate header (HTTP)401401 — 401 Bearer error="invalid_token" (HTTP)401401 — 401 because the Authorization header is stripped (HTTP)401401

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.