{"record":{"id":"a931e0804d8f613f","repo":"Sonarr/Sonarr","slug":"failed-to-connect-to-qbittorrent-check-your-setti-a931e0","errorCode":null,"errorMessage":"Failed to connect to qBittorrent. Check your settings and qBittorrent configuration.","messagePattern":"Failed to connect to qBittorrent\\. Check your settings and qBittorrent configuration\\.","errorType":"exception","errorClass":"DownloadClientException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs","lineNumber":51,"sourceCode":"\n            try\n            {\n                var response = _httpClient.Execute(request.Build());\n\n                // Version request will return 404 if it doesn't exist.\n                if (response.StatusCode == HttpStatusCode.NotFound)\n                {\n                    return false;\n                }\n\n                if (response.StatusCode == HttpStatusCode.Forbidden)\n                {\n                    return true;\n                }\n\n                if (response.StatusCode == HttpStatusCode.Unauthorized)\n                {\n                    throw new DownloadClientException(\"Failed to connect to qBittorrent. Check your settings and qBittorrent configuration.\", new HttpException(response));\n                }\n\n                if (response.HasHttpError)\n                {\n                    throw new DownloadClientException(\"Failed to connect to qBittorrent, check your settings.\", new HttpException(response));\n                }\n\n                return true;\n            }\n            catch (WebException ex)\n            {\n                if (ex.Status == WebExceptionStatus.TrustFailure)\n                {\n                    throw new DownloadClientUnavailableException(\"Unable to connect to qBittorrent, certificate validation failed.\", ex);\n                }\n\n                throw new DownloadClientException(\"Failed to connect to qBittorrent, check your settings.\", ex);\n            }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs#L33-L69","documentation":"Thrown by QBittorrentProxyV2.IsApiSupported when the v2 API support probe (GET /api/v2/app/webapiVersion) returns 401 Unauthorized. This means qBittorrent requires authentication even for this unauthenticated probe, which occurs when 'Bypass authentication for clients on localhost' is disabled and no API key or credentials are configured.","triggerScenarios":"IsApiSupported is called (during download client initialization) against a qBittorrent instance that returns 401 on the unauthenticated webapiVersion request.","commonSituations":"Fresh qBittorrent install with default security settings requiring auth; credentials not configured in the download client; qBittorrent accessed remotely with localhost auth bypass disabled; qBittorrent auth settings changed.","solutions":["Set username and password (or API key) in the qBittorrent download client settings.","Alternatively, enable 'Bypass authentication for clients on localhost' in qBittorrent WebUI options if the application runs on the same host.","Verify qBittorrent's WebUI authentication settings (Options > Web UI).","Test accessing the qBittorrent WebUI URL in a browser to confirm auth requirements."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure credentials or API key are configured before API detection\nif (settings.ApiKey.IsNullOrWhiteSpace() &&\n    (settings.Username.IsNullOrWhiteSpace() || settings.Password.IsNullOrWhiteSpace()))\n{\n    throw new DownloadClientAuthenticationException(\n        \"qBittorrent requires authentication. Set username/password or API key in settings.\");\n}","typeGuard":"static bool IsApiDetectionAuthFailure(DownloadClientException ex) =>\n    ex.InnerException is HttpException http && http.Response.StatusCode == HttpStatusCode.Unauthorized;","tryCatchPattern":"try\n{\n    var supported = proxyV2.IsApiSupported(settings);\n}\ncatch (DownloadClientException ex) when (ex.InnerException is HttpException { Response.StatusCode: HttpStatusCode.Unauthorized })\n{\n    _logger.Error(\"qBittorrent requires authentication for API access. Configure credentials or API key.\");\n    throw;\n}","preventionTips":["Always configure credentials or an API key for qBittorrent, even for local installations.","Enable 'Bypass authentication for clients on localhost' in qBittorrent only for local deployments.","Test the qBittorrent WebUI URL in a browser to confirm authentication requirements.","Validate settings completeness before calling IsApiSupported."],"tags":["qbittorrent","authentication","http-401","api-detection","download-client","v2-api"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}