diff --git a/proxy/http/server.go b/proxy/http/server.go
index e1f371b6..57f86c34 100644
--- a/proxy/http/server.go
+++ b/proxy/http/server.go
@@ -118,14 +118,11 @@ Start:
 		return trace
 	}
 
-	if len(s.config.Accounts) > 0 {
+  	if len(s.config.Accounts) > 0 {
 		user, pass, ok := parseBasicAuth(request.Header.Get("Proxy-Authorization"))
-		if !ok {
-			_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n\r\n"))
-			return err
-		}
-		if !s.config.HasAccount(user, pass) {
-			_, err := conn.Write([]byte("HTTP/1.1 401 UNAUTHORIZED\r\n\r\n"))
+		if !ok || !s.config.HasAccount(user, pass) {
+			_, err := conn.Write([]byte("HTTP/1.1 407 Proxy Authentication Required\r\n" +
+			"Proxy-Authenticate: Basic realm=\"V2Ray\"\r\n\r\n"))
 			return err
 		}
 	}
diff --git a/testing/scenarios/http_test.go b/testing/scenarios/http_test.go
index d0033def..0e4752ae 100644
--- a/testing/scenarios/http_test.go
+++ b/testing/scenarios/http_test.go
@@ -284,7 +284,7 @@ func TestHttpBasicAuth(t *testing.T) {
 			setProxyBasicAuth(req, "a", "c")
 			resp, err := client.Do(req)
 			assert(err, IsNil)
-			assert(resp.StatusCode, Equals, 401)
+			assert(resp.StatusCode, Equals, 407)
 		}
 
 		{