
Quick Answer
A proxy PAC file is a small JavaScript file that tells a compatible browser or application whether each request should connect directly or use a particular proxy server. A standard PAC file defines `FindProxyForURL(url, host)`, which returns instructions such as `DIRECT`, `PROXY proxy.example.net:3128`, or an ordered list of fallback routes. Some Microsoft clients also support the IPv6-aware `FindProxyForURLEx` extension.
PAC files are useful when one fixed proxy setting is too blunt. A company can route requests to public websites through a forward proxy, keep internal services direct, and assign a separate route to selected domains. The PAC file makes the routing decision. The chosen proxy endpoint then handles the connection, while the proxy service determines the exit IP and session behavior.
Key Takeaways
- Standard PAC files define `FindProxyForURL(url, host)` and return a valid routing string. Some Microsoft clients support `FindProxyForURLEx` for IPv6-aware rules.
- `DIRECT` bypasses the proxy, while `PROXY`, `HTTPS`, and `SOCKS5` select different proxy connection types where the client supports them.
- Semicolon-separated return values create an ordered candidate list. The PAC client determines whether it tries later entries and which failures trigger another attempt.
- PAC support differs between browsers, operating systems, command-line tools, and application libraries. A system PAC setting does not control every application.
- Proxy credentials do not belong in the PAC file. Authentication is handled separately by the browser, operating system, extension, or managed policy.
- PAC rules select a route for a request. They do not rotate the exit IP, preserve cookies, or choose between routes that share one endpoint and differ only by credentials.
PAC Files in Plain English
PAC stands for Proxy Auto-Configuration. Instead of giving a browser one proxy for every website, a PAC file supplies a decision function. The browser calls that function before a request and follows the returned instruction.
The basic shape is simple:
Need proxy infrastructure for this workflow? Compare residential and mobile proxy options.
This rule sends every eligible request through the same HTTP proxy. A useful PAC file normally adds conditions for internal hosts, selected domains, protocols, or fallback routes.
The PAC file runs in a restricted environment supplied by the client. It can use a set of PAC-specific helpers, but it is not a webpage script and cannot assume that browser APIs such as `window`, `document`, or `fetch` exist. The MDN PAC reference documents the standard function and commonly available helpers.
PAC files solve request routing. A proxy switcher lets a person change configurations through a browser interface. Provider-side IP rotation changes the exit IP after the client selects a proxy endpoint.
How PAC Routing Works
For each eligible request, the client passes two values to the PAC function:
- `url`: the requested URL, although the client may remove parts of it.
- `host`: the hostname without its port.
The function evaluates its rules from top to bottom and returns a route. A typical request follows this sequence:
- The user or application requests a URL.
- The client loads or reuses its configured PAC file.
- The client calls the PAC entry point it supports, normally `FindProxyForURL(url, host)`.
- The function returns a direct route or one or more proxy candidates.
- The client attempts a returned route according to its own proxy and fallback rules.
- If the client treats a failure as eligible for fallback, it may try the next candidate.
For example, a rule can return `DIRECT` for `service.corp.example`, an HTTP proxy for `api.example.com`, and a default proxy for everything else. The first matching `return` ends the decision for that request.
Do not build important PAC rules around a URL path or query string. Chromium removes the path, query, fragment, and any embedded username or password from HTTPS URLs before passing them to `FindProxyForURL()`. Its maintainers also advise against depending on those components for HTTP URLs. Hostname-based routing is more portable across clients.
Valid PAC Return Values
PAC routing instructions use a compact format rather than ordinary proxy URLs.
| Return value | Meaning | Compatibility note |
|---|---|---|
| `DIRECT` | Connect without a proxy | Exposes the direct network route to the destination |
| `PROXY host:port` | Use an HTTP proxy | The most widely supported proxy result |
| `HTTP host:port` | Use an HTTP proxy | Supported by Firefox; support in other PAC clients varies |
| `HTTPS host:port` | Use an encrypted connection to an HTTP proxy | Not every PAC client supports this result; test the target client |
| `SOCKS host:port` | Use an unqualified SOCKS proxy | Often treated as SOCKS4, so avoid ambiguity |
| `SOCKS4 host:port` | Use SOCKS4 | No proxy-side hostname resolution in Chromium |
| `SOCKS5 host:port` | Use SOCKS5 | Authentication and DNS behavior depend on the client |
| `PROXY a:3128; PROXY b:3128` | Try the listed proxies in order | Fallback normally reacts to connection failures, not every HTTP error |
| `PROXY a:3128; DIRECT` | Try the proxy, then permit a direct connection | A failed proxy can expose the client's direct route |
An HTTP proxy can carry HTTPS destination traffic through an HTTP CONNECT tunnel. `PROXY host:port` therefore does not mean the browser is limited to unencrypted websites. The browser establishes the tunnel and then performs TLS with the destination through it.
The `HTTPS` PAC result describes an encrypted client-to-proxy connection. It is not another name for sending HTTPS destinations through an ordinary HTTP proxy. This distinction matters when comparing HTTP and SOCKS5 proxy behavior.
A Working PAC File Example
The following example keeps internal hosts direct, routes one API domain through a primary and backup proxy, and sends all other eligible traffic through a default proxy:
All domains and proxy endpoints in this example are placeholders. Replace them with approved internal domains and the exact proxy connection details supplied for your environment.
The rule handles both the exact hostname and its subdomains. `dnsDomainIs(host, ".api.example.com")` matches a host such as `v1.api.example.com`, but the exact comparison is still needed for `api.example.com` itself.
The API rule has no `DIRECT` entry. After both proxies fail, the client's policy determines what happens next. Firefox, for example, may offer the user a temporary direct connection. Add `; DIRECT` only when direct access is acceptable.
The direct rule names `intranet` explicitly instead of bypassing every single-label hostname. Chromium applies its own implicit bypass rules to localhost names, link-local IP literals, and unspecified IP literals, so those requests can bypass the proxy regardless of the PAC return value. Add `isPlainHostName(host)` only when every plain hostname should connect directly.
PAC Functions Worth Using
Most PAC files need only a few helper functions. Simpler rules are easier to test and less likely to behave differently across clients.
| Function | Practical use | Important limitation |
|---|---|---|
| `isPlainHostName(host)` | Match a hostname without a dot | Can bypass more names than intended |
| `dnsDomainIs(host, domain)` | Match a hostname suffix | Handle the exact base hostname separately when needed |
| `localHostOrDomainIs(host, hostdom)` | Match a local name or its full form | Best suited to known internal naming schemes |
| `shExpMatch(value, pattern)` | Match a shell-style pattern | Broad patterns can catch unrelated hosts |
| `isResolvable(host)` | Check whether local DNS can resolve a host | Adds a DNS lookup during route selection |
| `dnsResolve(host)` | Obtain a locally resolved address | Can add latency and expose a local DNS lookup |
| `isInNet(host, pattern, mask)` | Match an IPv4 address or resolved host against a network | May resolve the hostname locally first |
| `myIpAddress()` | Obtain one address associated with the client | Ambiguous on devices with several network interfaces |
| `weekdayRange()` and related time helpers | Change routes by time or date | Client clock and time-zone handling affect the result |
Start with direct hostname comparisons, `dnsDomainIs()`, and carefully scoped pattern matching. DNS-dependent functions can slow PAC evaluation because route selection may wait for a lookup before the actual request begins. They can also produce different results when internal and external DNS return different answers for the same name.
Legacy helpers such as `dnsResolve()` and `isInNet()` are designed around IPv4 addresses. Microsoft documents IPv6-aware `Ex` helpers and `FindProxyForURLEx`, but those extensions are not portable to every PAC engine. Keep shared PAC files on the common helper set unless every target client has been tested. The Microsoft IPv6 PAC extensions describe the additional functions.
`myIpAddress()` is especially fragile on laptops connected to Wi-Fi, a wired network, a VPN, or several virtual interfaces. It returns one address, which may not represent the interface an administrator expected. Use it only after testing every network state that matters.
PAC File vs Web Proxy Auto-Discovery (WPAD), Manual Settings, and `NO_PROXY`
These controls can all affect proxy routing, but they work at different layers.
| Method | What it does | Best fit |
|---|---|---|
| PAC file | Runs rules that choose a proxy or direct route for each request | Several destination-based routing policies |
| WPAD | Attempts to discover the PAC file URL through network configuration | Managed networks that deliberately operate discovery infrastructure |
| Manual proxy | Applies a fixed proxy plus a bypass list | One stable route with a few exceptions |
| `NO_PROXY` | Tells a compatible process which destinations should bypass its proxy variables | Command-line tools, services, and containers that honor it |
| Provider rotation | Selects or changes the exit behind a proxy endpoint | Rotating or sticky proxy sessions after the client chooses the endpoint |
A PAC file is the routing script. WPAD is one way to discover where that script is hosted. They are related, but they are not synonyms. Microsoft describes the WinHTTP AutoProxy sequence as PAC URL discovery, file download, and then `FindProxyForURL()` execution for requests made by compatible applications.
An explicit PAC URL is usually easier to audit than discovery because administrators know which file clients should load. WPAD requires a controlled DHCP or DNS configuration and careful security review. A client that does not support PAC or WPAD will ignore those rules even if the operating system uses them elsewhere.
Hosting and Deploying a PAC File
A PAC file should be small, directly reachable, and protected from unauthorized changes. If a client cannot obtain the file, its fallback behavior can determine whether requests fail, use a manual proxy, or connect directly.
Use this deployment checklist:
- Save the script as a UTF-8 file with a `.pac` extension, such as `proxy.pac`.
- Host it at a stable, trusted HTTPS URL that managed clients can reach without first using the proxy.
- Return an HTTP `200` response for the PAC URL.
- Serve `application/x-ns-proxy-autoconfig; charset=utf-8` or another client-supported PAC content type with an explicit charset.
- Keep the script small and avoid unnecessary DNS lookups.
- Restrict write access and deploy changes through review and version control.
- Stage the file with a small client group before a wider rollout.
- Keep the previous working version ready for rollback.
- Decide whether a PAC fetch failure may fall back to direct access.
Use HTTP only when a controlled environment requires it and the security tradeoff has been reviewed. A PAC file controls where browser traffic goes, so an attacker who changes it can redirect requests through an unauthorized proxy. Trusted HTTPS protects the file in transit, while access controls protect it at the host.
Chromium's proxy implementation documentation places additional limits on PAC downloads. The request must complete within 30 seconds, return exactly `200`, and contain an uncompressed body smaller than 1 MB. Chromium fetches the PAC URL directly rather than through a proxy, and the fetch cannot prompt for HTTP credentials or use client certificates.
A common deployment failure occurs when the PAC file is available only through the proxy it is supposed to configure. A new client cannot load the instructions needed to reach that proxy. Place the file on a network path available before proxy routing starts.
Do not expect every browser to download an updated file on the next page load. Chromium can retain the last successfully loaded PAC file until the network or proxy settings change, the response is older than 12 hours, or the user invalidates it. Firefox provides a Reload control for its configured PAC URL. Plan a refresh method before an emergency change is needed.
How to Configure a PAC URL
The exact menu names can change between operating-system releases, and managed policies can override local settings. These are the usual desktop paths:
- Windows with Chrome or Edge: Open Settings > Network & internet > Proxy, enable Use setup script, enter the PAC URL, and save. Chrome and Edge normally use the applicable Windows proxy configuration unless a managed browser policy replaces it.
- Firefox: Open Settings > Privacy & Security > Connection and software security > Advanced settings > Proxy settings, click Configure proxy, select Automatic proxy configuration URL, enter the PAC URL, and save. Use Reload after later PAC file changes.
- macOS and Safari: Open System Settings > Network, select the active network service, open Details > Proxies, enable Automatic Proxy Configuration, and enter the PAC URL. Safari follows the macOS network service configuration.
After setup, test one destination from every branch. Loading an ordinary page proves only that the browser can connect, not that it selected the intended route.
Browser and Tool Support
PAC compatibility belongs to the client, not to the website being requested. Two applications on the same computer can follow different routes.
| Client or environment | PAC support | What to check |
|---|---|---|
| Chrome and Edge | Yes, through supported system, policy, or browser configuration | URL sanitization, PAC caching, fallback, and proxy authentication |
| Firefox | Yes, with a direct PAC URL, auto-detect, or applicable system settings | Use the Reload control after an update |
| Safari | Yes, through the active macOS network service | Automatic Proxy Configuration URL and managed settings |
| WinHTTP application | Only when the application uses the relevant AutoProxy functions | WinHTTP accepts HTTP and HTTPS PAC URLs, not file URLs |
| Docker Desktop | Supports a statically configured PAC URL in applicable host settings | Do not assume WPAD discovery is supported |
| cURL and libcurl | No built-in PAC execution | Resolve the route separately and pass the chosen proxy explicitly |
| Custom application | Library-dependent | Confirm PAC execution, return formats, DNS behavior, and authentication |
Docker separates host, daemon, build, and container network settings. The Docker proxy configuration explains where a PAC URL can affect Docker Desktop and where an application still needs its own proxy setting.
Firefox documents its Automatic proxy configuration URL setting and a Reload button. Apple's macOS proxy settings provide separate controls for automatic discovery and a specified PAC URL. Record the configuration method for each client instead of telling users only to "enable automatic proxy settings."
The official cURL FAQ confirms that cURL and libcurl do not execute PAC files because they do not include JavaScript support. You can still use cURL with a proxy after another component resolves the PAC rule, but cURL will not evaluate `FindProxyForURL()` itself.
Proxy Authentication Stays Outside the PAC File
When a PAC file selects a proxy, its return value supplies the proxy type, hostname, and port. `DIRECT` selects no proxy. The return format has no field for a proxy username or password. Do not place credentials in the script, append them to the PAC URL, or assume that `PROXY user:password@host:port` is portable.
Authentication can come from a browser prompt, stored browser credentials, operating-system controls, an extension, source-IP allowlisting, or an enterprise authentication system. The usable method depends on the proxy protocol and the client.
Chromium supports common HTTP proxy authentication flows but does not support username-and-password authentication for SOCKS5. A Chromium browser using an authenticated SOCKS5 endpoint therefore needs a compatible alternative, such as source-IP allowlisting when the source address is stable, or an HTTP proxy endpoint that supports the browser's authentication flow.
An HTTP `407 Proxy Authentication Required` response means the proxy rejected or did not receive acceptable credentials. It does not mean the destination rejected a website login. Follow the 407 troubleshooting process and protect any secrets using the same controls applied to other proxy credentials.
DNS, Fallback, and Direct-Connection Risk
PAC evaluation and destination DNS resolution are separate events. A function such as `dnsResolve(host)` can perform a local lookup while deciding on a route. After the decision, the selected proxy protocol determines where the destination hostname is resolved.
Chromium delegates destination-name resolution to HTTP proxies. With SOCKS5, Chromium sends the destination hostname to the selected SOCKS5 proxy for resolution. Other clients can behave differently, especially with SOCKS5. If DNS location or privacy matters, verify the route with the actual browser rather than inferring it from the PAC return string. See how DNS servers resolve names for the full lookup sequence.
A list such as `PROXY a:3128; PROXY b:3128; DIRECT` gives the client ordered candidates, but each client decides when to move to the next one. In Chromium, a proxy DNS failure or a failed connection to the proxy can trigger another candidate. An ordinary destination response such as `404`, `403`, or `429` does not automatically make the browser abandon that proxy and try the next route.
Chromium also remembers temporarily failed proxies and can reorder later attempts. The browser may therefore choose the backup first even though the PAC file still lists the primary first. This stateful behavior is one reason a single successful page load is not enough to validate fallback.
Treat `DIRECT` as a network-policy choice, not a harmless recovery word. When it is the final fallback, the destination can receive the direct network's public egress IP if the proxies fail. Omitting `DIRECT` is necessary for a fail-closed route, but it may not be sufficient because PAC fetch failures or client prompts can still permit direct access. Enforce the intended client policy and test every failure path.
Testing a PAC File Before Deployment
Test the routing result, the actual connection, and the failure behavior. A syntax check alone cannot prove that the browser used the intended proxy.
The open-source pacparser project includes `pactester`, which can evaluate common PAC rules from a terminal. Install it using the project's documented package or build instructions, then run representative URLs against the local file:
For the sample file above, the expected results are:
- The primary API proxy followed by the backup proxy.
- `DIRECT` for the internal domain.
- The default proxy.
`pactester` is a fast logic check, not a substitute for client testing. PAC engines differ, and the browser still controls authentication, DNS, caching, implicit bypass rules, and fallback.
Complete the test with these cases:
- One hostname for every routing branch.
- The exact base hostname and a subdomain for every suffix rule.
- Mixed-case hostnames.
- A destination that must never connect directly.
- An unreachable primary proxy to test the backup route.
- An unreachable PAC URL to observe fetch-failure behavior.
- A valid request through the intended browser and operating system.
- A route check using an approved IP-check endpoint and proxy-side logs.
A full proxy test should also confirm authentication, observed location, latency, returned content, and session behavior. Avoid logging credentials or full PAC URLs if those URLs contain sensitive deployment tokens.
Troubleshooting a PAC File
Trace the request in order: confirm that the client loaded the PAC file, matched the intended rule, selected the expected route, and reached the proxy. This isolates the stage that failed.
| Symptom | Likely cause | First check |
|---|---|---|
| Every request goes direct | PAC fetch failure, default `DIRECT`, or unsupported client | PAC URL response, client support, and final return statement |
| Every request uses the proxy | Broad pattern or a bypass rule that never matches | Rule order and one known bypass hostname |
| PAC changes are ignored | The client is using a cached copy | Client reload, network change, policy refresh, or documented invalidation control |
| `407 Proxy Authentication Required` | Missing, rejected, or unsupported proxy credentials | Browser authentication method, credential scope, and allowlisted source IP |
| `ERR_PROXY_CONNECTION_FAILED` | Unreachable proxy hostname or port | DNS, firewall, endpoint, port, and protocol |
| Browsing pauses before a connection starts | Slow PAC fetch or DNS-heavy helper functions | PAC response time and calls to `dnsResolve()` or `isResolvable()` |
| A rule works in one browser only | Different PAC engine or URL sanitization | Browser-specific support and path-dependent logic |
| A command works in a browser but fails in cURL | cURL does not execute PAC | Resolve the route and pass the proxy explicitly |
| The backup proxy is tried first | Primary was temporarily marked as failed | Client proxy state and connection-failure history |
| Internal traffic reaches an external proxy | Missing or incorrect bypass rule | Exact hostname, base-host handling, suffix match, and rule order |
| Traffic connects directly after an outage | `DIRECT` fallback, a PAC fetch fallback, or a client prompt | Returned proxy list, managed policy, and whether direct fallback is disabled |
| Chromium SOCKS5 authentication fails | SOCKS5 credentials are unsupported in Chromium | Use a compatible HTTP route or stable source-IP allowlisting |
For Chromium, a NetLog capture can show the resolved proxy list, proxies marked as failed, and the effective order used for a request. For Firefox, reload the configured PAC file before repeating the test. When a browser extension also controls proxy settings, confirm whether it overrides the operating-system PAC configuration. The SwitchyOmega setup shows how extension-managed proxy profiles differ from a system PAC deployment.
Do not respond to a certificate error by turning off verification. Identify whether the failed certificate belongs to the PAC host, proxy endpoint, destination, or an authorized inspection system, then repair the relevant trust configuration.
Using a PAC File With Proxidize
A PAC file can direct compatible browser traffic to a Proxidize endpoint. The proxy hostname and port identify where the client connects. Proxidize then applies the selected product's targeting, authentication, and rotating or sticky session settings. The PAC file does not replace those settings.
Use the connection details generated for the chosen product instead of copying a host or port from an unrelated example. A `PROXY` route to an HTTP proxy has the broadest PAC compatibility and can carry HTTPS destination traffic through CONNECT. For a Proxidize HTTPS proxy connection, use the `pg.proxi.es` DNS hostname rather than an IP address. HTTP and HTTPS use the same credentials and endpoint port. SOCKS5 remains an option when the client supports both the protocol and the required authentication method.
Proxy endpoint ports are separate from destination ports. Current Proxidize limits and specifications allow proxy traffic to destination ports `80` and `443`.
Per GB access points need special care. With username/password authentication, Residential Per GB and Mobile Per GB connections can share the same gateway hostname and protocol port while the username identifies the access point and its routing settings. Changing an access point's settings also changes its generated username, so copy the current credentials again after making a change. A PAC return value cannot choose between same-endpoint access points that differ only by credentials.
For one Per GB route, the browser can use the generated endpoint with one set of proxy credentials stored or supplied by the client. If different destinations must use different Per GB access points, use separate browser instances, client configurations, or another design that can associate the correct credentials with each route. The PAC file cannot perform that credential selection by itself.
Choose Proxidize Residential Proxies for worldwide coverage with country, city, or ISP targeting where inventory is available. Choose Proxidize Mobile Proxies when the workflow requires a U.S. mobile-network route. In either case, PAC handles the client's destination-based routing while the Proxidize configuration controls the available exit network and session behavior.
Begin with a small browser test. Confirm the PAC result, proxy authentication, observed exit, returned content, and direct-fallback policy before rolling the configuration out to more users.
Frequently asked questions
No. A PAC file contains the routing logic. WPAD attempts to discover the PAC file's URL through network configuration. A client can use a PAC file from an explicitly configured URL without using WPAD.
PAC return values define proxy schemes, hostnames, ports, and fallback order. They do not provide a portable field for credentials. Keep proxy authentication outside the PAC file and use a method supported by the browser and proxy protocol.
Yes. Conditional rules can return different proxies for different destinations, and a single return value can list several candidates separated by semicolons. The client tries eligible fallback routes according to its own failure rules and any proxy failures it has cached.
The PAC file chooses whether the request uses a proxy. If it selects a proxy, the destination ordinarily sees the proxy's exit IP. The PAC file itself does not rotate that IP or determine the provider's exit-selection behavior.
No. cURL and libcurl do not include a JavaScript engine for PAC execution. Pass a proxy explicitly after resolving the required route through another component.
PAC refresh behavior is client-specific. Firefox provides a Reload control. Chromium treats the last successful PAC response as fresh until the network or proxy configuration changes, the response is more than 12 hours old, or the user invalidates PAC through browser network controls. Once the response becomes stale, Chromium fetches the PAC URL again the next time it resolves a proxy route.
Only when direct access is acceptable. A final `DIRECT` entry can keep browsing available after eligible proxy failures, but it can also expose the direct network's public egress IP and bypass the intended proxy route.