{"record":{"id":"34d3e6a7b8a5ea3b","repo":"arduino/Arduino","slug":"unable-to-fetch-pac-file-at-pac-response-code-i","errorCode":null,"errorMessage":"Unable to fetch PAC file at {pac}. Response code is {responseCode}","messagePattern":"Unable to fetch PAC file at (.+?)\\. Response code is (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/net/CustomProxySelector.java","lineNumber":85,"sourceCode":"      return pacProxy(pac, uri);\n    }\n\n    if (Constants.PROXY_TYPE_MANUAL.equals(proxyType)) {\n      return manualProxy();\n    }\n\n    throw new IllegalStateException(\"Unable to understand proxy settings\");\n  }\n\n  private Proxy pacProxy(String pac, URI uri) throws IOException, ScriptException, NoSuchMethodException {\n    setAuthenticator(preferences.get(Constants.PREF_PROXY_USERNAME), preferences.get(Constants.PREF_PROXY_PASSWORD));\n\n    URLConnection urlConnection = new URL(pac).openConnection();\n    urlConnection.connect();\n    if (urlConnection instanceof HttpURLConnection) {\n      int responseCode = ((HttpURLConnection) urlConnection).getResponseCode();\n      if (responseCode != 200) {\n        throw new IOException(\"Unable to fetch PAC file at \" + pac + \". Response code is \" + responseCode);\n      }\n    }\n    String pacScript = new String(IOUtils.toByteArray(urlConnection.getInputStream()), Charset.forName(\"ASCII\"));\n\n    ScriptEngine nashorn = new ScriptEngineManager().getEngineByName(\"nashorn\");\n    nashorn.getBindings(ScriptContext.ENGINE_SCOPE).put(\"pac\", new PACSupportMethods());\n    Stream.of(\"isPlainHostName(host)\",\n      \"dnsDomainIs(host, domain)\",\n      \"localHostOrDomainIs(host, hostdom)\",\n      \"isResolvable(host)\",\n      \"isInNet(host, pattern, mask)\",\n      \"dnsResolve(host)\",\n      \"myIpAddress()\",\n      \"dnsDomainLevels(host)\",\n      \"shExpMatch(str, shexp)\").forEach((fn) -> {\n      try {\n        nashorn.eval(\"function \" + fn + \" { return pac.\" + fn + \"; }\");\n      } catch (ScriptException e) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/net/CustomProxySelector.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the PAC URL in system proxy settings is correct and returns 200 (curl -I the URL)","Fix or update the PAC file location on the proxy server","Temporarily set proxy manually instead of automatic PAC configuration in Arduino IDE preferences","Check for corporate proxies/VPN requiring authentication to reach the PAC server"],"exampleFix":"// before (system proxy points to dead PAC)\njava.net.useSystemProxies=true\n// after\n// set manual proxy in IDE prefs or -Dhttp.proxyHost=proxy.corp.com -Dhttp.proxyPort=8080","handlingStrategy":"validation","validationCode":"HttpURLConnection c = (HttpURLConnection) new URL(pacUrl).openConnection();\nif (c.getResponseCode() != 200) {\n    throw new IOException(\"PAC file not reachable: \" + pacUrl + \" -> \" + c.getResponseCode());\n}","typeGuard":null,"tryCatchPattern":"try {\n    proxies = proxySelector.select(uri);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"Unable to fetch PAC file\")) {\n        // fall back to DIRECT or manual proxy\n    }\n}","preventionTips":["Verify the PAC URL with curl -I before relying on it","Keep PAC hosting inside always-reachable infrastructure","Prefer manual proxy settings when PAC is flaky","Monitor the PAC server's availability"],"tags":["network","proxy","pac","http"],"backgroundTag":"http-non-200-response","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}