Error 401 Authorization Required: a password box you did not expect

The short answer: when a folder or a site opens a box asking for a username and password from the browser itself (not a page of the site), a password protection is active on the server. Error 401 is what appears if you cancel the box or the details are wrong. It is not a fault: it is a protection that is on.

Where the box comes from

Origin How to recognise it What to do
cPanel “Directory Privacy” It was you (or whoever built the site) who protected the folder. If you still want it, use the details you created; if not, remove the protection: Password protecting a folder.
Lines in .htaccess (AuthType Basic, AuthUserFile) Someone added the rules by hand, or a security plugin did. Look at the folder’s .htaccess and remove the lines, after keeping a copy.
A test or under-construction site Whoever created it put a password to hide it. Ask whoever created it for the details, or remove the protection when it is time to open.
An API asking for identification The 401 comes from an API address and not from a page. Check the request’s key or user: see the API documentation.
You filled in the details and it asks again Wrong username or password, or the browser autofilling old ones. Type by hand, in a private tab. If you lost the password, create the protection again in cPanel.

How to remove or change the protection

1 In cPanel, open “Directory Privacy” and look for the folder.
2 Choose the folder and switch off the password protection option, or change the username and password.
3 If it is not in the list, the protection is in the .htaccess: open that folder’s file and remove the AuthType, AuthName, AuthUserFile and Require valid-user lines.
4 Confirm in another browser that the box no longer appears.
If the site should be public and the box appears, Google and visitors are shut out: only content in view appears in searches. Check before announcing a new site: Before you publish your website. And a simple password protection does not replace other defences: Keeping your server secure.

Not sure who put the protection on or lost the details? Open a ticket with the folder’s address.

Open a support ticket

SEE ALSO

Password protecting a folder with Directory Privacy

.htaccess for PHP projects: friendly URLs and redirects

Before you publish your website: a ten-point launch checklist

Website errors explained: 500, 403, 404, 508 and what to do

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $5.36/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?