How to Test a PAC File in Chrome
Published
Choose two test destinations
A proxy auto-configuration (PAC) file tells Chrome which route to use for a request. To test that decision, use two HTTPS URLs you control in an approved test environment. Serve a small, uncached response at each URL without redirects. If you can, log the remote address and timestamp at each origin so you have another way to confirm which route carried the request.
https://via-proxy.pac-lab.test/checkshould go through your approved proxy.https://direct.pac-lab.test/checkshould connect directly, where your setup explicitly allows that connection.
Replace the example hostnames with your own. The proxy must be able to resolve and reach the proxied destination, and the test machine must be able to resolve and reach the direct destination. Use certificates trusted by the test machine. Chrome applies implicit exceptions for loopback and link-local addresses, so use ordinary hostnames backed by test servers for this check. Chromium’s proxy documentation
Create a small PAC file
Save the following as proxy.pac. Replace the gateway and port with your approved HTTP proxy. The exact hostname match keeps the direct route limited to one host. Every other request evaluated by this script gets the proxy as its only candidate.
function FindProxyForURL(url, host) {
if (host === 'direct.pac-lab.test') {
return 'DIRECT';
}
return 'PROXY gateway.pac-lab.test:3128';
}
Serve the file from an approved HTTPS URL with Content-Type: application/x-ns-proxy-autoconfig and an HTTP 200 response containing the script. Chrome fetches the PAC URL directly, so confirm that the test machine can reach it without using the proxy that the script configures. An example file URL is https://direct.pac-lab.test/proxy.pac. Keep credentials out of the file. Chromium’s PAC download requirements
Set the script address on Windows
Use an approved, isolated Windows test machine or virtual machine where changing system proxy settings and reaching the direct test host are authorized. Other apps can also use those system settings, so keep ordinary browsing outside the test environment. In Chrome, open chrome://policy and check for proxy policies such as ProxySettings. If policy or a managed extension controls the proxy, ask the administrator to apply the approved test configuration. Chrome Enterprise proxy settings policy
When Chrome uses Windows proxy settings, record the current settings first. Open Settings → Network & internet → Proxy. Under Use setup script, select Set up, enable the script, enter the HTTPS address of the PAC file, and select Save. Restore the previous setup after testing. Microsoft’s Windows proxy setup instructions
Record what Chrome actually connects to
- Open
chrome://net-export/in the Chrome profile you’re testing. Keep the default Strip private information capture mode and select Start Logging To Disk. - Keep that tab open. In a separate tab in the same profile, load each HTTPS test URL once and note when you opened it.
- Stop logging. Inspect the JSON locally or with a viewer approved for these logs. Even a default capture can contain internal hostnames and URLs. Chromium’s NetLog capture instructions
Check that the effective settings in the viewer’s proxy overview show your PAC URL. Then find each request and follow its linked events. PROXY_RESOLUTION_SERVICE_RESOLVED_PROXY_LIST shows the parsed result of proxy resolution. Look for an HTTP proxy entry on one request and DIRECT on the other. When reading the JSON directly, constants.logEventTypes maps event names to numeric types. Chromium’s guide to reading proxy events
Chrome can reorder the effective list after failures when a PAC file offers multiple candidates. Follow the fallback, stream and socket events to see which connection served the request. Expect the proxy gateway and an HTTP CONNECT tunnel for the proxied HTTPS request, and the destination itself for the direct one. If both routes share a public IP, match the request timestamps against your proxy logs. An exit IP check in Chrome shows the address seen by a particular destination.
If you see an unexpected route, check the active PAC URL and any PAC download or script errors first. Chrome can fall back to another route when PAC loading fails, depending on the configuration. If Chrome chooses the expected proxy but the request fails, check the tunnel or authentication separately. Troubleshoot a failed Chrome proxy tunnel