{"record":{"id":"d3e2e3ac9bb74b3a","repo":"Sonarr/Sonarr","slug":"failed-to-authenticate-with-qbittorrent","errorCode":null,"errorMessage":"Failed to authenticate with qBittorrent.","messagePattern":"Failed to authenticate with qBittorrent\\.","errorType":"exception","errorClass":"DownloadClientAuthenticationException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV1.cs","lineNumber":366,"sourceCode":"                _authCookieCache.Remove(authKey);\n\n                var authLoginRequest = BuildRequest(settings).Resource(\"/login\")\n                                                             .Post()\n                                                             .AddFormParameter(\"username\", settings.Username ?? string.Empty)\n                                                             .AddFormParameter(\"password\", settings.Password ?? string.Empty)\n                                                             .Build();\n\n                HttpResponse response;\n                try\n                {\n                    response = _httpClient.Execute(authLoginRequest);\n                }\n                catch (HttpException ex)\n                {\n                    _logger.Debug(\"qbitTorrent authentication failed.\");\n                    if (ex.Response.StatusCode == HttpStatusCode.Forbidden)\n                    {\n                        throw new DownloadClientAuthenticationException(\"Failed to authenticate with qBittorrent.\", ex);\n                    }\n\n                    throw new DownloadClientException(\"Failed to connect to qBittorrent, please check your settings.\", ex);\n                }\n                catch (WebException ex)\n                {\n                    throw new DownloadClientUnavailableException(\"Failed to connect to qBittorrent, please check your settings.\", ex);\n                }\n\n                if (response.Content != \"Ok.\")\n                {\n                    // returns \"Fails.\" on bad login\n                    _logger.Debug(\"qbitTorrent authentication failed.\");\n                    throw new DownloadClientAuthenticationException(\"Failed to authenticate with qBittorrent.\");\n                }\n\n                _logger.Debug(\"qBittorrent authentication succeeded.\");\n","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV1.cs#L348-L384","documentation":"Thrown by QBittorrentProxyV1.AuthenticateClient when the v1 login endpoint (POST /login) returns HTTP 403 Forbidden. This is an explicit authentication rejection, surfaced as DownloadClientAuthenticationException so callers can distinguish credential problems from connectivity problems. A 403 on login typically means the IP is banned or access is restricted.","triggerScenarios":"POST to /login returns 403 Forbidden — qBittorrent's IP ban kicked in after repeated failed login attempts, or an IP whitelist is active and the client's IP is not on it.","commonSituations":"Too many failed login attempts triggered qBittorrent's brute-force protection (default: ban after 6 failed attempts); qBittorrent IP whitelist enabled without the application's IP; qBittorrent WebUI authentication configured with restrictions.","solutions":["Verify username and password in download client settings are correct.","Check qBittorrent WebUI options for IP ban settings (Options > Web UI > 'Ban client after too many failed authentication attempts') and clear any temporary ban by restarting qBittorrent.","If an IP whitelist is enabled, add the application host's IP to it.","Test the same credentials by logging into the qBittorrent WebUI in a browser."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate credentials are set before calling proxy\nif (!settings.Username.IsNullOrWhiteSpace() && !settings.Password.IsNullOrWhiteSpace())\n{\n    if (settings.Username.Length > 50 || settings.Password.Length > 200)\n        throw new InvalidOperationException(\"qBittorrent credentials appear truncated or malformed.\");\n}","typeGuard":"static bool IsAuthRejection(DownloadClientException ex) => ex is DownloadClientAuthenticationException && ex.InnerException is HttpException { Response: { StatusCode: HttpStatusCode.Forbidden } };","tryCatchPattern":"try\n{\n    proxy.GetTorrents(settings);\n}\ncatch (DownloadClientAuthenticationException ex) when (ex.InnerException is HttpException { Response.StatusCode: HttpStatusCode.Forbidden })\n{\n    _logger.Error(\"qBittorrent rejected auth (403). Check for IP ban or whitelist.\");\n    throw;\n}","preventionTips":["Verify credentials match by testing login in the qBittorrent WebUI before configuring the download client.","Disable or raise the IP ban threshold in qBittorrent (Options > Web UI) if the application makes frequent connections.","Add the application host's IP to qBittorrent's whitelist if one is configured.","Monitor for repeated auth failures that could trigger IP bans."],"tags":["qbittorrent","authentication","http-403","ip-ban","download-client","v1-api"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}