arduino/Arduino · error · IOException
Too many redirect {requestURL}
Error message
Too many redirect {requestURL} What it means
Thrown by the private recursive makeConnection when a URL request exceeds the allowed redirect-following limit (movedTimes). HttpConnectionManager follows HTTP 3xx Location redirects up to a fixed cap; if the server keeps responding with redirects past that cap (redirect loop, auth bounce, etc.), this fires with the original requestURL. It means the target URL never yielded a direct response — fix the URL or the server's redirect behavior.
Source
Thrown at arduino-core/src/cc/arduino/utils/network/HttpConnectionManager.java:109
}
public HttpURLConnection makeConnection(Consumer<HttpURLConnection> beforeConnection)
throws IOException, NoSuchMethodException, ScriptException, URISyntaxException {
return makeConnection(this.requestURL, 0, beforeConnection);
}
public HttpURLConnection makeConnection()
throws IOException, NoSuchMethodException, ScriptException, URISyntaxException {
return makeConnection(this.requestURL, 0, (c) -> {
});
}
private HttpURLConnection makeConnection(URL requestURL, int movedTimes,
Consumer<HttpURLConnection> beforeConnection) throws IOException, URISyntaxException, ScriptException, NoSuchMethodException {
if (movedTimes > maxRedirectNumber) {
throw new IOException("Too many redirect " + requestURL);
}
Proxy proxy = new CustomProxySelector(PreferencesData.getMap()).getProxyFor(requestURL.toURI());
final String requestId = UUID.randomUUID().toString().toUpperCase().replace("-", "").substring(0, 16);
HttpURLConnection connection = (HttpURLConnection) requestURL.openConnection(proxy);
// see https://github.com/arduino/Arduino/issues/10264
// Workaround for https://bugs.openjdk.java.net/browse/JDK-8163921
connection.setRequestProperty("Accept", "*/*");
connection.setRequestProperty("User-agent", userAgent);
connection.setRequestProperty("X-Request-ID", requestId);
if (id != null) {
connection.setRequestProperty("X-ID", id);
}
if (requestURL.getUserInfo() != null) {
String auth = "Basic " + new String(View on GitHub (pinned to a0df6e0e83)
Solutions
- Verify the final URL resolves correctly (curl -IL <url>) and fix server-side redirect loops
- Remove one hop by using the final destination URL directly
- Increase maxRedirectNumber if the chain is legitimately long
- Bypass or fix the proxy that is injecting redirects
Example fix
// before
HttpURLConnection c = new HttpConnectionManager(url).makeConnection(consumer);
// after: use the resolved final URL
HttpURLConnection head = (HttpURLConnection) url.openConnection();
head.setInstanceFollowRedirects(false);
String loc = head.getHeaderField("Location");
URL finalUrl = (loc != null) ? new URL(loc) : url;
HttpURLConnection c = new HttpConnectionManager(finalUrl).makeConnection(consumer); Defensive patterns
Strategy: try-catch
Validate before calling
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setInstanceFollowRedirects(false);
if (c.getResponseCode() >= 300 && c.getResponseCode() < 400) {
String loc = c.getHeaderField("Location");
if (loc != null && new URL(loc).equals(url)) throw new IllegalStateException("Redirect loop");
} Try / catch
try {
connection = new HttpConnectionManager(url).makeConnection(before);
} catch (IOException e) {
if (e.getMessage().startsWith("Too many redirect")) {
throw new IllegalStateException("Resolve redirect loop for " + url, e);
} else throw e;
} Prevention
- Point directly at final (non-redirecting) URLs
- Fix http->https redirect loops on servers you control
- Keep redirect chains short; test with curl -IL
- Avoid captive-portal or auth-loop URLs for automated downloads
When it happens
Trigger: makeConnection() recursively follows 3xx Location headers; movedTimes exceeds maxRedirectNumber for requestURL, commonly a redirect loop or a redirect chain longer than the configured limit.
Common situations: Server redirect loop (http->https misconfig, login loops); a redirect chain of 5+ hops; a misbehaving proxy rewriting Location headers; URL pointing to a captive portal.
Related errors
- Exceeded %s redirects.
- Error downloading {0}
- Unable to fetch PAC file at {pac}. Response code is {respons
- Received invalid http status code from server: {resp}
- Received response with content-encoding: %s, but failed to d
AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06).
Data as JSON: /api/errors/fe31648abb94b7c5.
Report an issue: GitHub.