diff --git a/lib/url.c b/lib/url.c
index 74a69050a5b4d8bd7db77c0b6e5f8c8c7c91b3e9..83aa6e3b2b7e7de117ec52f784c87d0a29be2c2b 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1086,15 +1086,15 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
       infof(data, "Couldn't find host %s in the .netrc file, using defaults",
             data->hostname);
     }
+    else
+      data->bits.user_passwd = 1; /* enable user+password */
+
     /* weather we failed or not, we don't know which fields that were filled
        in anyway */
     if(!data->user[0])
       strcpy(data->user, CURL_DEFAULT_USER);
     if(!data->passwd[0])
       strcpy(data->passwd, CURL_DEFAULT_PASSWORD);
-    if(conn->protocol&PROT_HTTP) {
-      data->bits.user_passwd = 1; /* enable user+password */
-    }
   }
   else if(!(data->bits.user_passwd) &&
 	  (conn->protocol & (PROT_FTP|PROT_HTTP)) ) {