I have a problem with htpasswd.

I get an error in error.log apache2

user admin: authentication failure for "/": Password Mismatch

Content of my htaccess file:

# Set Access Restrictions

AuthType Basic
AuthName "admin"
AuthUserFile ".htpasswd"
require valid-user

and content of my htpasswd

  • 2
    What did you use to generate your .htpasswd file? Aug 5 '15 at 15:02
  • with notepad++ and I changed the name ...there is another software ?? Aug 5 '15 at 15:50
  • See this page: httpd.apache.org/docs/2.2/programs/htpasswd.html It my be that you did not edit the file correctly. As well, passwords must be 8 characters. There are also limitations with .htpasswd on Apache on Windows.
    – closetnoc
    Aug 5 '15 at 16:18

From your comment I take it that you just created a plain text password. This will not work for Apache, as Apache expects the password in .htpasswd to be hashed by the MD5 algorithm.

There are several tools available online for generating .htpasswd files, but the easiest might be the one that comes with Apache, it's called htpasswd. On RHEL (Fedora, Red Hat, CentOS) systems you'll need the httpd-tools package (yum install httpd-tools). On Ubuntu systems it's in the apache2-utils package (apt-get install apache2-utils). If you're using XAMPP on Windows it's in the folder xampp\apache\bin.

To use htpasswd with the .htaccess file you've already got configured, you'd simply do htpasswd /protected/.htpasswd user and then type in your desired password (twice) when prompted. It will then generate your .htpasswd file in the /protected/ directory.


Make sure that you are including the entire path for AuthUserFile. I would suggest that you create a protected directory instead of doing this on the root directory. I made sure and tested these configurations to ensure that they worked.

File Locations


.htaccess File

AuthType Basic
AuthName "restricted area"
AuthUserFile /protected/.htpasswd
require valid-user

. htpasswd File


Make sure that the password is MD5'd, here is a tool.


Finally, I have not hash a password to md5 .... I've used notepad ++ and I put the password in simple character

I followed this tutorial with the linux command for create file htaccess

enter image description here

now my content of my htpasswd :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.