Sonarr/Sonarr · error · DownloadClientAuthenticationException

Failed to authenticate with qBittorrent.

Error message

Failed to authenticate with qBittorrent.

What it means

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.

Source

Thrown at src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV1.cs:366

                _authCookieCache.Remove(authKey);

                var authLoginRequest = BuildRequest(settings).Resource("/login")
                                                             .Post()
                                                             .AddFormParameter("username", settings.Username ?? string.Empty)
                                                             .AddFormParameter("password", settings.Password ?? string.Empty)
                                                             .Build();

                HttpResponse response;
                try
                {
                    response = _httpClient.Execute(authLoginRequest);
                }
                catch (HttpException ex)
                {
                    _logger.Debug("qbitTorrent authentication failed.");
                    if (ex.Response.StatusCode == HttpStatusCode.Forbidden)
                    {
                        throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.", ex);
                    }

                    throw new DownloadClientException("Failed to connect to qBittorrent, please check your settings.", ex);
                }
                catch (WebException ex)
                {
                    throw new DownloadClientUnavailableException("Failed to connect to qBittorrent, please check your settings.", ex);
                }

                if (response.Content != "Ok.")
                {
                    // returns "Fails." on bad login
                    _logger.Debug("qbitTorrent authentication failed.");
                    throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.");
                }

                _logger.Debug("qBittorrent authentication succeeded.");

View on GitHub (pinned to da2284d7ea)

Solutions

  1. Verify username and password in download client settings are correct.
  2. 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.
  3. If an IP whitelist is enabled, add the application host's IP to it.
  4. Test the same credentials by logging into the qBittorrent WebUI in a browser.
Defensive patterns

Strategy: validation

Validate before calling

// Validate credentials are set before calling proxy
if (!settings.Username.IsNullOrWhiteSpace() && !settings.Password.IsNullOrWhiteSpace())
{
    if (settings.Username.Length > 50 || settings.Password.Length > 200)
        throw new InvalidOperationException("qBittorrent credentials appear truncated or malformed.");
}

Type guard

static bool IsAuthRejection(DownloadClientException ex) => ex is DownloadClientAuthenticationException && ex.InnerException is HttpException { Response: { StatusCode: HttpStatusCode.Forbidden } };

Try / catch

try
{
    proxy.GetTorrents(settings);
}
catch (DownloadClientAuthenticationException ex) when (ex.InnerException is HttpException { Response.StatusCode: HttpStatusCode.Forbidden })
{
    _logger.Error("qBittorrent rejected auth (403). Check for IP ban or whitelist.");
    throw;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13). Data as JSON: /api/errors/d3e2e3ac9bb74b3a. Report an issue: GitHub.