arduino/Arduino · error · IOException

Unable to fetch PAC file at {pac}. Response code is {respons

Error message

Unable to fetch PAC file at {pac}. Response code is {responseCode}

What it means

Thrown by CustomProxySelector.pacProxy when fetching a Proxy Auto-Configuration (PAC) script over HTTP does not return HTTP 200. Arduino IDE fetches the PAC file to evaluate the proxy script for network proxies; a non-200 response means the script could not be retrieved, so proxy resolution cannot proceed.

Source

Thrown at arduino-core/src/cc/arduino/net/CustomProxySelector.java:85

      return pacProxy(pac, uri);
    }

    if (Constants.PROXY_TYPE_MANUAL.equals(proxyType)) {
      return manualProxy();
    }

    throw new IllegalStateException("Unable to understand proxy settings");
  }

  private Proxy pacProxy(String pac, URI uri) throws IOException, ScriptException, NoSuchMethodException {
    setAuthenticator(preferences.get(Constants.PREF_PROXY_USERNAME), preferences.get(Constants.PREF_PROXY_PASSWORD));

    URLConnection urlConnection = new URL(pac).openConnection();
    urlConnection.connect();
    if (urlConnection instanceof HttpURLConnection) {
      int responseCode = ((HttpURLConnection) urlConnection).getResponseCode();
      if (responseCode != 200) {
        throw new IOException("Unable to fetch PAC file at " + pac + ". Response code is " + responseCode);
      }
    }
    String pacScript = new String(IOUtils.toByteArray(urlConnection.getInputStream()), Charset.forName("ASCII"));

    ScriptEngine nashorn = new ScriptEngineManager().getEngineByName("nashorn");
    nashorn.getBindings(ScriptContext.ENGINE_SCOPE).put("pac", new PACSupportMethods());
    Stream.of("isPlainHostName(host)",
      "dnsDomainIs(host, domain)",
      "localHostOrDomainIs(host, hostdom)",
      "isResolvable(host)",
      "isInNet(host, pattern, mask)",
      "dnsResolve(host)",
      "myIpAddress()",
      "dnsDomainLevels(host)",
      "shExpMatch(str, shexp)").forEach((fn) -> {
      try {
        nashorn.eval("function " + fn + " { return pac." + fn + "; }");
      } catch (ScriptException e) {

View on GitHub (pinned to a0df6e0e83)

Solutions

  1. Verify the PAC URL in system proxy settings is correct and returns 200 (curl -I the URL)
  2. Fix or update the PAC file location on the proxy server
  3. Temporarily set proxy manually instead of automatic PAC configuration in Arduino IDE preferences
  4. Check for corporate proxies/VPN requiring authentication to reach the PAC server

Example fix

// before (system proxy points to dead PAC)
java.net.useSystemProxies=true
// after
// set manual proxy in IDE prefs or -Dhttp.proxyHost=proxy.corp.com -Dhttp.proxyPort=8080
Defensive patterns

Strategy: validation

Validate before calling

HttpURLConnection c = (HttpURLConnection) new URL(pacUrl).openConnection();
if (c.getResponseCode() != 200) {
    throw new IOException("PAC file not reachable: " + pacUrl + " -> " + c.getResponseCode());
}

Try / catch

try {
    proxies = proxySelector.select(uri);
} catch (IOException e) {
    if (e.getMessage().contains("Unable to fetch PAC file")) {
        // fall back to DIRECT or manual proxy
    }
}

Prevention

When it happens

Trigger: The URL configured as the PAC file (from Java system properties like java.net.useSystemProxies / proxy settings) returns an HTTP status other than 200 (e.g. 404, 403, 500) during getProxyFor() proxy resolution.

Common situations: Corporate environments where the PAC URL in system/auto-detected proxy settings is stale, points behind an intranet-only server, requires credentials, or the PAC server is down; also proxies that intercept and rewrite PAC responses.

Related errors


AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06). Data as JSON: /api/errors/34d3e6a7b8a5ea3b. Report an issue: GitHub.