Sonarr/Sonarr · error · WebException
Remote website tried to redirect without providing a locatio
Error message
Remote website tried to redirect without providing a location.
What it means
Raised inside DownloadFromWebUrl when the indexer responds with a 3xx redirect (301/302/303) but the Location header is absent or null. Auto-redirect is explicitly disabled (request.AllowAutoRedirect = false) so Sonarr can detect magnet-redirects, and a redirect without a target is treated as a protocol violation. Wrapped later as WebException -> ReleaseDownloadException.
Source
Thrown at src/NzbDrone.Core/Download/TorrentClientBase.cs:166
response.StatusCode == HttpStatusCode.SeeOther)
{
var locationHeader = response.Headers.GetSingleValue("Location");
_logger.Trace("Torrent request is being redirected to: {0}", locationHeader);
if (locationHeader != null)
{
if (locationHeader.StartsWith("magnet:"))
{
return DownloadFromMagnetUrl(remoteEpisode, indexer, locationHeader);
}
request.Url += new HttpUri(locationHeader);
return await DownloadFromWebUrl(remoteEpisode, indexer, request.Url.ToString());
}
throw new WebException("Remote website tried to redirect without providing a location.");
}
torrentFile = response.ResponseData;
_logger.Debug("Downloading torrent for episode '{0}' finished ({1} bytes from {2})", remoteEpisode.Release.Title, torrentFile.Length, torrentUrl);
}
catch (HttpException ex)
{
if (ex.Response.StatusCode is HttpStatusCode.NotFound or HttpStatusCode.Gone)
{
_logger.Error(ex, "Downloading torrent file for episode '{0}' failed since it no longer exists ({1})", remoteEpisode.Release.Title, torrentUrl);
throw new ReleaseUnavailableException(remoteEpisode.Release, "Downloading torrent failed", ex);
}
if ((int)ex.Response.StatusCode == 429)
{
_logger.Error("API Grab Limit reached for {0}", torrentUrl);
}View on GitHub (pinned to da2284d7ea)
Solutions
- Open the .torrent URL in a browser/curl -i and verify a Location header is present on any redirect.
- If a reverse proxy/CDN strips Location, fix the proxy config to preserve it.
- Update or correct the indexer grab URL so it does not rely on a broken redirect.
- Report the empty-redirect bug to the indexer if it reproduces on their endpoint.
Example fix
// before: any missing Location is a hard WebException
throw new WebException("Remote website tried to redirect without providing a location.");
// after: tolerate and retry the original URL or surface a clearer error
_logger.Warn("Redirect {0} from {1} had no Location; retrying original URL",
response.StatusCode, torrentUrl);
throw new ReleaseDownloadException(remoteEpisode.Release,
"Redirect from indexer missing Location header", ex); Defensive patterns
Strategy: validation
Validate before calling
// Inspect redirect responses for a Location before relying on them
var location = response.Headers.GetSingleValue("Location");
if ((int)response.StatusCode is >= 300 and < 400 && location.IsNullOrWhiteSpace())
{
_logger.Warn("Redirect {0} from {1} lacks Location; ignoring redirect",
response.StatusCode, torrentUrl);
// fall through to treat response body as the torrent, or retry
} Type guard
static bool HasUsableRedirect(HttpResponse r)
=> (int)r.StatusCode is >= 300 and < 400
&& r.Headers.GetSingleValue("Location").IsNullOrWhiteSpace() == false; Try / catch
try { /* fetch torrent */ }
catch (WebException ex) when (ex.Message.Contains("redirect without providing a location"))
{
_logger.Warn("Indexer returned a Location-less redirect for {0}", torrentUrl);
// mark indexer as degraded, try alternate release
} Prevention
- Do not assume 3xx always carries Location - validate before following.
- Ensure reverse proxies preserve the Location header.
- Log redirect chains for indexer endpoints to catch stripping early.
- Prefer direct .torrent URLs over redirect-dependent ones.
When it happens
Trigger: The .torrent URL returns MovedPermanently/Found/SeeOther and the response headers contain no 'Location' value (locationHeader == null at TorrentClientBase.cs:154-166). Happens with misconfigured indexers, reverse proxies that strip the Location header, or server bugs.
Common situations: A CDN or reverse proxy (nginx, Cloudflare) rewrites redirect responses and drops the Location header; the indexer endpoint was deprecated and issues an empty redirect; a captive portal redirects without a Location; the server returns a 302 body but the header name casing is unusual and GetSingleValue misses it.
Related errors
- Too many automatic redirections were attempted for {autoRedi
- Site responded with browser content instead of api data. Thi
- Indexer API call returned an unexpected StatusCode [{0}]
- Failed to read complete http response
- Http request timed out
AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13).
Data as JSON: /api/errors/3ecef89411d3c580.
Report an issue: GitHub.