{"record":{"id":"0c153e65bd8f5f91","repo":"docker/cli","slug":"login-attempt-to-s-failed-with-status-d-s","errorCode":null,"errorMessage":"login attempt to %s failed with status: %d %s","messagePattern":"login attempt to (.+?) failed with status: (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/registry/auth.go","lineNumber":70,"sourceCode":"\t\tcredentialAuthConfig = *authConfig\n\t\tcreds                = loginCredentialStore{authConfig: &credentialAuthConfig}\n\t)\n\n\tloginClient, err := v2AuthHTTPClient(endpoint.URL, authTrans, modifiers, creds, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tresp, err := loginClient.Do(req)\n\tif err != nil {\n\t\terr = translateV2AuthError(err)\n\t\treturn \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\t// TODO(dmcgowan): Attempt to further interpret result, status code and error code string\n\t\treturn \"\", fmt.Errorf(\"login attempt to %s failed with status: %d %s\", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))\n\t}\n\n\treturn credentialAuthConfig.IdentityToken, nil\n}\n\nfunc v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifiers []transport.RequestModifier, creds auth.CredentialStore, scopes []auth.Scope) (*http.Client, error) {\n\tchallengeManager, err := PingV2Registry(endpoint, authTransport)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tauthHandlers := []auth.AuthenticationHandler{\n\t\tauth.NewTokenHandlerWithOptions(auth.TokenHandlerOptions{\n\t\t\tTransport:     authTransport,\n\t\t\tCredentials:   creds,\n\t\t\tOfflineAccess: true,\n\t\t\tClientID:      AuthClientID,\n\t\t\tScopes:        scopes,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/internal/registry/auth.go#L52-L88","documentation":"Returned by loginV2 when the registry `/v2/` GET (with auth handlers attached) does not return HTTP 200. The endpoint URL, numeric status, and http.StatusText are interpolated. It signals that authentication against the registry endpoint failed (401, 403, 5xx, etc.).","triggerScenarios":"Calling registry.Auth (docker login to a registry) whose endpoint responds with a non-200 to the authenticated /v2/ probe — bad credentials, insufficient privileges, registry down, or wrong endpoint.","commonSituations":"Wrong password/token; account disabled; private registry returning 401; registry behind a proxy returning 502/503; using a PAT where the registry wants username/password; rate-limited (429).","solutions":["Verify credentials and the registry server address are correct.","Check the exact status code in the message: 401/403 -> credentials, 5xx -> registry side, 429 -> rate limit.","Ensure you are reaching the intended endpoint (not a proxy/login portal).","For Docker Hub, confirm the PAT has the needed scopes / account is in good standing."],"exampleFix":"# before (wrong token)\necho $WRONG_TOKEN | docker login registry.example.com -u user --password-stdin\n# login attempt to https://registry.example.com/v2/ failed with status: 401 Unauthorized\n# after: use correct PAT\necho $CORRECT_PAT | docker login registry.example.com -u user --password-stdin","handlingStrategy":"try-catch","validationCode":"// pre-flight: ensure the endpoint answers before full login\nif _, err := registry.PingV2Registry(endpoint, transport); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if errdefs.IsUnauthorized(err) { /* prompt for correct creds */ }\nif errdefs.IsUnavailable(err) { /* registry-side, retry later */ }","preventionTips":["Validate credentials before scripting `docker login`.","Read the embedded status code to classify (401 vs 5xx vs 429).","Use --password-stdin to avoid credential mistakes."],"tags":["registry","auth","login","http-status","docker"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}