On this page (7 sections)
An HTTP 401 Unauthorized response means the server received your request but did not get acceptable proof of identity. Visitors see a short error page or a browser password box, and API clients see a failed call. If the error hits your admin area, you can be locked out of fixing anything else.
This guide is for site owners, developers and hosting admins. It draws on a recent Sucuri post on HTTP 401 (published 2026-10-20) and adds a practical diagnosis workflow. This is a troubleshooting topic, not a vulnerability disclosure, so there is no CVE or severity rating.
What a 401 actually means
According to Sucuri, a 401 signals that authentication has failed: the request was valid, but no acceptable credentials came with it. They may be missing, malformed, expired or incorrect, so the server refuses to serve the resource.
The name is slightly misleading. "Unauthorized" is closer to "unauthenticated": the server does not know who you are. If it knows who you are and still says no, it returns a 403 instead. That difference is the first thing to check when deciding where to look.
A well-formed 401 includes a WWW-Authenticate header naming the scheme the server expects, such as Basic or Bearer. That header is also what makes a browser show a username and password dialog. If you can see it, you know which system is challenging the request.
Why it matters beyond the inconvenience
- Human visitors hit a dead end and leave, which costs trust and conversions.
- Search crawlers treat the URL as inaccessible, so public pages that return 401 can drop out of the index while the problem persists (per Sucuri).
- If the affected URL is your login or admin path, you cannot repair other problems until it is resolved.
- API and app traffic gets a JSON or XML error body and failed jobs downstream, rather than a visible error page.
Common causes
Sucuri notes that causes cluster into a few layers, and identifying the layer is most of the work. Some are mundane credential problems, others are configuration issues, and a few are security events.
| Cause | What it looks like | Where to check |
|---|---|---|
| Wrong, expired or revoked credentials | Password changed, API key rotated, bearer token expired, service account disabled | The credential store or secrets used by the client |
| Broken or stale login session | Logged-in users appear anonymous after a domain change, www/non-www switch, HTTP-to-HTTPS move, or a plugin that regenerates session keys | Browser cookies, site URL settings, session-related plugins |
| Server-level HTTP authentication | Browser password box on a protected directory, often via .htaccess and .htpasswd on Apache or equivalent Nginx directives | Web server config, existence and path of the password file |
The source text available to us is cut off after the server-level authentication cause, so other layers it may describe (for example CDN, proxy or plugin rules) are not covered here as source-backed claims.
How to diagnose a 401
Start by finding which layer is asking for credentials. A read-only request that prints only the response headers shows the status code and any WWW-Authenticate challenge. Run it from any machine with curl and replace the URL with the failing one; look for the status line and the WWW-Authenticate header.
curl -sI https://example.com/wp-admin/Then interpret the result:
- WWW-Authenticate: Basic suggests server-level password protection (for example .htpasswd) or a proxy or host-level login in front of the site.
- WWW-Authenticate: Bearer suggests an API or token-based layer, so check that the token is present, correct and unexpired.
- A 401 with no browser dialog and an application error body points to the application or an API client rather than the web server.
- A 403 instead of 401 means the server knows who you are, so look at permissions and access rules, not credentials.
If you suspect a server-level rule, check whether your Apache or Nginx configuration references a password file and whether that file still exists at the stated path. A missing or moved password file is a predictable way for directory protection to break.
find /var/www -name .htpasswd -o -name .htaccess 2>/dev/null
grep -rn "AuthUserFile\|auth_basic" /etc/apache2 /etc/nginx 2>/dev/nullWhat to do now
0 of 8 done
If WordPress is involved and you cannot reach wp-admin, you can still list plugins from the command line with WP-CLI to see what changed recently.
wp plugin listWhen a 401 may point to a security problem
Sucuri highlights the case that matters most for security teams: a sudden wave of 401s can signal a deeper compromise rather than a simple configuration mistake. The available text does not give the full indicators, so treat the following as general guidance rather than claims from the source.
- A spike of 401 responses on login or XML-RPC/REST endpoints from many addresses can indicate password guessing. Compare the timing with your access logs.
- Unexpected changes to .htaccess, password files or authentication settings that nobody on your team made deserve investigation.
- 401s that begin right after an unfamiliar plugin, theme or file change should be checked against your change history.
awk '$9 == 401 {print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | headThe log path and field position assume the common combined log format; Apache logs are often under /var/log/apache2/ on Debian and Ubuntu. If a few addresses dominate, consider rate limiting or blocking them at your firewall. If you find unexplained file changes, follow our guide on what to do when a website is hacked.
Preventing repeat 401 errors
- Document where credentials live and who rotates them, so expiry does not surprise you.
- Plan domain, www and HTTPS migrations with session cookies and site URLs in mind.
- Keep server-level password protection to the paths that need it and monitor that the password file remains in place.
- Monitor key URLs so an unexpected 401 or certificate problem is noticed quickly. Webforta Monitor covers uptime, certificate, DNS and header changes.
- Review login and admin traffic in your logs regularly, and see our WordPress security checklist for hardening basics.
Sources
This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.
