TeamNewPipe/NewPipe · error · HttpDataSourceException
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
Error message
Too many redirects: {} What it means
Thrown by YoutubeHttpDataSource when the open loop follows more redirects than the configured maximum (redirectCount exceeds the maxRedirects cap). It is wrapped as an HttpDataSourceException with cause NoRouteToHostException and ExoPlayer error code ERROR_CODE_IO_NETWORK_CONNECTION_FAILED, type OPEN. This is ExoPlayer's data-source layer for YouTube video playback URLs.
Source
Thrown at app/src/main/java/org/schabi/newpipe/player/datasource/YoutubeHttpDataSource.java:592
|| httpURLConnectionResponseCode == HttpURLConnection.HTTP_MOVED_PERM
|| httpURLConnectionResponseCode == HttpURLConnection.HTTP_MOVED_TEMP
|| httpURLConnectionResponseCode == HttpURLConnection.HTTP_SEE_OTHER)) {
httpURLConnection.disconnect();
final boolean shouldKeepPost = keepPostFor302Redirects
&& responseCode == HttpURLConnection.HTTP_MOVED_TEMP;
if (!shouldKeepPost) {
// POST request follows the redirect and is transformed into a GET request.
httpMethod = DataSpec.HTTP_METHOD_GET;
httpBody = null;
}
url = handleRedirect(url, location, dataSpecToUse);
} else {
return httpURLConnection;
}
}
// If we get here we've been redirected more times than are permitted.
throw new HttpDataSourceException(
new NoRouteToHostException("Too many redirects: " + redirectCount),
dataSpecToUse,
PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED,
HttpDataSourceException.TYPE_OPEN);
}
/**
* Configures a connection and opens it.
*
* @param url The url to connect to.
* @param httpMethod The http method.
* @param httpBody The body data, or {@code null} if not required.
* @param position The byte offset of the requested data.
* @param length The length of the requested data, or {@link C#LENGTH_UNSET}.
* @param allowGzip Whether to allow the use of gzip.
* @param followRedirects Whether to follow redirects.
* @param requestParameters parameters (HTTP headers) to include in request.
* @return the connection openedView on GitHub (pinned to 9e8be09156)
Solutions
- Increase the maxRedirects cap on the YoutubeHttpDataSource.Factory so legitimate multi-hop CDN chains can complete.
- Refresh the playback URL before playback so it has a fresh signature and does not bounce through re-signing redirects.
- Inspect the redirect chain (intermediate Location values) to identify a redirect loop, then fix the source of the loop (e.g. expired params).
- If behind a corporate proxy, configure the proxy correctly so YouTube's CDN redirects resolve directly.
- Retry playback: transient redirect storms from CDN load balancing often resolve on the next attempt with a freshly resolved URL.
Example fix
// before factory.setMaxRedirects(5); // after factory.setMaxRedirects(20);
Defensive patterns
Strategy: retry
Validate before calling
if (redirectCount > maxRedirects) {
// refresh the playback URL before attempting to follow more redirects
} Try / catch
try {
dataSource.open(dataSpec);
} catch (final HttpDataSourceException e) {
if (e.getCause() instanceof NoRouteToHostException) {
// refresh playback URL and retry once
}
throw e;
} Prevention
- Configure a generous maxRedirects on the DataSource.Factory to accommodate CDN hop chains.
- Use freshly resolved/signed playback URLs to avoid redirect storms from expired params.
- Detect redirect loops by tracking visited URLs and bailing early with a clearer error.
- Retry playback once with a re-resolved URL before surfacing the failure.
When it happens
Trigger: The YouTube /videoplayback URL returns a chain of 3xx responses (301/302/303/307/308) whose hop count exceeds the DataSource's maxRedirects setting before a non-redirect response is received. The makeConnection loop keeps calling handleRedirect until it runs out of allowed hops.
Common situations: YouTube CDN rotating between multiple video cache nodes in a loop or a very long chain, a stale/expired playback URL that bounces between redirect endpoints, a misconfigured mirror/proxy that redirects to itself, or a geographically distant client that gets bounced across regional nodes. Also when the itag/URL params have expired and YouTube keeps redirecting to re-signed URLs.
Related errors
- Invalid content length
- reCaptcha Challenge requested
- Unsupported type: {}
- Generation of YouTube DASH manifest for {} is not supported
- Error when generating the DASH manifest of YouTube ended liv
AI-assisted analysis of TeamNewPipe/NewPipe@9e8be09156 (2026-08-14).
Data as JSON: /api/errors/10b91b73a3814375.
Report an issue: GitHub.