Browser keeps asking for username and password (Basic auth prompt loop)
The login dialog reappears after entering credentials, because the server keeps answering 401.
basic auth prompt keeps reappearingpassword prompt loop 401user not found htpasswdpassword mismatch htpasswdAuthUserFile not found 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
.htpasswdmissing or unreadable by the web server user- Wrong
AuthUserFilepath - Authorization header stripped by a proxy
- Password hash type unsupported (bcrypt/apr1 mismatch)
⚡ Quick fix
- Check the server error log for the exact reason
- Recreate the entry:
htpasswd -B /etc/nginx/.htpasswd user - Fix permissions so the web server can read the file
Detailed fix by platform
Linux
- 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
- Error log — Which reason?
- htpasswd — Readable?
- 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:
Similar errors
Most viewed in HTTP
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 18 Nov 2026