Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set auth basic in nginx and blocked other ips like:

location / {
   auth_basic "Restricted Area";
   auth_basic_user_file .htpasswd;
   deny all;

I can login using the username/password provided in .htpasswd but the error log in nginx shows errors like:

user "memcache" was not found in "/etc/nginx/.htpasswd"
no user/password was provided for basic authentication

Any suggestion why this occurs and how to get rid of it ?

share|improve this question
up vote 1 down vote accepted

It might not be the perfect solutions, but I had to add memcache as the new user to .htpasswd file. Now, I don't have that error of user not found. But that no user/password was provided for basic authentication is still occurring. I had explored all over and found this post from Igor Sysoev The creator of Nginx:

The HTTP Basic authentication works as following:

  • A browser requests a page without user/password.
  • A server response with 401 page, sending realm as well.
  • At this stage the 401 code appears in access_log and the message "no user/password ..." appears in error_log.
  • The browser shows a realm/login/password prompt.
  • If a user will press cancel, then the browser will show the received 401 page.
  • If the user enters login/password, then the browser repeats the request with login/password.

Then until you will exit the browser, it will send these login/password with all requests in protected hierarchy.

share|improve this answer

I did not have to add the user memcache rather I only had to install memcached and then it worked for me.

server {
        # Change these settings to match your machine
        listen 80;

           satisfy any;

           deny all;

        # Restrict Access
           auth_basic  "Restricted";
           auth_basic_user_file /var/www/.htpasswd;

        access_log /var/log/nginx/domain_access.log;
        error_log /var/log/nginx/domain_error.log;

        # deny access to .htaccess files
        location ~ /\.ht {
                deny all;

share|improve this answer
memcache and memcached are almost similar how they work, so, adding memcached instead shouldn't really solve the issue, given I have installed memcached too. As Igor said Nginx checks for authentication with every browser request. All browsers cache the internal auth and doesn't prompt for password everytime, so Nginx logs this as auth failure. – Jhilke Dai Jun 12 '14 at 7:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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