Back to all posts
How to Configure Proxy Bypass Lists for Local and Internal Traffic

How to Configure Proxy Bypass Lists for Local and Internal Traffic

October 8, 2026

When you enable a proxy for web scraping or API automation, the instinct is often to set it globally. This works for the target requests, but it introduces a hidden class of failures for everything else on your machine. If every packet—localhost, Docker containers, internal databases, and CI runners—routes through your proxy provider, you risk connection loops, latency spikes, and accidental data exfiltration of internal services.

Why Global Proxy Routing Breaks Local Development

The core issue lies in how proxy clients resolve destinations. A global proxy setting tells the operating system or application to forward all HTTP and TCP traffic to a specific gateway. For external requests, this is exactly what you want. For internal traffic, it is a liability.

The Connection Loop

When your scraper tries to reach localhost or 127.0.0.1 while a global proxy is active, the request may get forwarded to the proxy server. The proxy then attempts to resolve or connect to that address itself, often failing or looping back to your local machine through the gateway. This results in timeouts, ECONNREFUSED errors, or sluggish response times for local services like Redis, PostgreSQL, or your own API.

The Security Risk

Routing internal traffic through an external proxy exposes your private infrastructure to third-party servers. Internal IP ranges such as 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 contain sensitive service details. Without a bypass list, a misconfigured scraper could inadvertently tunnel database credentials or internal endpoints through a public proxy node.

The Performance Hit

Even if the traffic doesn't fail, it adds unnecessary hops. Internal requests usually resolve in milliseconds over a LAN. Forcing them through a residential or datacenter proxy adds round-trip latency to every local health check, cron job, or service discovery event.

Setting Up Environment Variables

The most common way to define a bypass list is the NO_PROXY environment variable. This is supported by most HTTP clients, including Python requests, Node.js, and cURL.

Syntax and Rules

The variable accepts a comma-separated list of hostnames, IP addresses, and domains. To make rules effective, follow these conventions:

  • Do not use a leading dot for IP addresses; use them exactly as they appear.
  • Use a leading dot for domains to match subdomains (e.g., .internal.example.com matches api.internal.example.com).
  • Use CIDR notation for IP ranges (e.g., 192.168.1.0/24).
  • Keep entries lowercase to avoid case-sensitivity issues on some platforms.

Example Configuration

For a typical developer environment, your configuration should look like this:

export NO_PROXY="localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,*.local"

This ensures that loopback addresses, private IPv4 ranges, and local domain suffixes never touch the proxy. Note that NO_PROXY must be exported in the same shell session that launches your scraping process. If you use a process manager like PM2 or Supervisor, configure the variable in their environment settings rather than your interactive terminal.

Configuring the Operating System

Some tools do not respect NO_PROXY and rely on the OS network settings instead. You should verify the system-wide proxy configuration.

Windows

Open Settings > Network & Internet > Proxy. Disable the "Use a proxy server" toggle for manual setup. Alternatively, use PowerShell to set the proxy exclusion list:

Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name 'ProxyOverride' -Value 'localhost;127.*;10.*;192.168.*;172.16.*;*.local'

macOS

Navigate to System Settings > Network > Details > Proxies. Ensure no proxy protocols are enabled for your active interface unless specifically needed. macOS respects NO_PROXY for many CLI tools, but GUI applications may require explicit system configuration.

Linux

Most Linux distributions rely on ~/.bashrc or ~/.profile. Add the export line to your shell configuration file so it persists across sessions:

echo 'export NO_PROXY="localhost,127.0.0.1,*.local"' >> ~/.bashrc
source ~/.bashrc

Handling Proxy-Auto-Config Files

In enterprise environments, proxies are often defined via a Proxy-Auto-Config (PAC) file. If you manage these files, you can define logic that directs internal traffic directly.

function FindProxyForURL(url, host) {
    if (shExpMatch(host, "*.internal.company.com")) {
        return "DIRECT";
    }
    if (dnsDomainIs(host, "127.0.0.1")) {
        return "DIRECT";
    }
    return "PROXY GATEWAY_HOST:HTTP_PORT";
}

The DIRECT keyword bypasses the proxy entirely. This is useful for centralized deployments where environment variables are difficult to manage across many machines.

Bypass Rules in Your Code

Even with system settings, applications may override them. It is best practice to handle bypass logic explicitly in your Python and Node scripts.

Python with Requests

The requests library respects NO_PROXY automatically, but you can enforce exclusions programmatically:

import requests
from urllib3.util import parse_url

proxies = {
    "http": "http://GATEWAY_HOST:HTTP_PORT",
    "https": "http://GATEWAY_HOST:HTTP_PORT",
}
bypass = ["localhost", "127.0.0.1", "192.168.1.50"]

def get_session(host):
    if any(b in host for b in bypass):
        return requests.Session()
    session = requests.Session()
    session.proxies.update(proxies)
    return session

Node.js with Fetch

Modern Node.js supports proxy bypass via the HTTP_PROXY handling in undici or manual logic:

const PROXY = "http://GATEWAY_HOST:HTTP_PORT";
const bypass = ["localhost", "127.0.0.1"];

async function fetch(url) {
    const parsed = new URL(url);
    if (bypass.includes(parsed.hostname)) {
        return fetch(url);
    }
    return fetch(url, { agent: new ProxyAgent(PROXY) });
}

cURL

Use the --noproxy flag to exclude hosts for specific commands:

curl --proxy "http://GATEWAY_HOST:HTTP_PORT" \
     --noproxy "localhost,127.0.0.1" \
     http://example.com

Verifying Your Bypass Rules

After configuring bypass lists, validate that internal traffic is not leaking. Use dig or curl with verbose output to inspect the resolved path.

curl -v --noproxy "*" http://localhost:8080/health

If the output shows a connection to 127.0.0.1 rather than the proxy IP, your configuration is working. Additionally, test a known internal IP to ensure it resolves via the LAN interface.

Best Practices

  • Always test bypass rules before scaling your scraper pool.
  • Combine environment variables with code-level exceptions for defense in depth.
  • Document your NO_PROXY list in your project's README so other team members avoid connectivity issues.
  • Review your proxy provider's terms to ensure internal traffic exclusion complies with your agreement.

By isolating internal traffic from your proxy chain, you protect your infrastructure, reduce latency, and ensure your scraping tools run reliably alongside your local development stack.