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.

Typical 401 causes and where to look
CauseWhat it looks likeWhere to check
Wrong, expired or revoked credentialsPassword changed, API key rotated, bearer token expired, service account disabledThe credential store or secrets used by the client
Broken or stale login sessionLogged-in users appear anonymous after a domain change, www/non-www switch, HTTP-to-HTTPS move, or a plugin that regenerates session keysBrowser cookies, site URL settings, session-related plugins
Server-level HTTP authenticationBrowser password box on a protected directory, often via .htaccess and .htpasswd on Apache or equivalent Nginx directivesWeb 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.

Show response headers for a failing URL (any system with curl)Shell
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.

Search a web root for HTTP auth files and directives (read-only, run on the server)Shell
find /var/www -name .htpasswd -o -name .htaccess 2>/dev/null
grep -rn "AuthUserFile\|auth_basic" /etc/apache2 /etc/nginx 2>/dev/null
Paths such as /var/www, /etc/apache2 and /etc/nginx are common on Debian and Ubuntu. Adjust them for your host layout. The commands only read files.

What to do now

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.

List installed plugins and their status (run in the WordPress root, read-only)WP-CLI
wp plugin list
Caution. Reloading Apache or Nginx after editing authentication rules affects live traffic. Test the configuration syntax first (for example apachectl configtest or nginx -t) and keep a copy of the original file before changing it.

When 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.
Count 401 responses per client address in an Apache or Nginx combined access log (read-only)Shell
awk '$9 == 401 {print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head

The 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.
Only one independent publisher covers this topic in our research, so the cause list above reflects Sucuri's view and our own general guidance, not multiple confirmations.

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.

  1. HTTP 401 Unauthorized: What It Means and How to Fix Itblog.sucuri.net ·
  • HTTP errors
  • 401
  • WordPress
  • troubleshooting
  • authentication