← Guides

Send Python requests through a fixed-IP proxy

Set the proxy on the HTTP client that calls your allowlisted API. Verify the direct route and the proxied route from the same machine before changing the destination firewall.

Updated 2026-11-24 · 5 min read

Set up a proxy user

Request route through your static IP Python application your code proxy (HTTPS) Your server 203.0.113.42 from 203.0.113.42 Partner API / DB allows 203.0.113.42
Only the calls you send through the proxy use your static IP. Every other request goes out directly, as before.
  1. Log in to the client area, open My Services and click your server. Scroll to Use your IP from code, n8n, CI or a browser. Under Add a proxy user, type python and click Add.
    MazeVPN client area: Add a proxy user, with the name python typed in
    You should see: a new card named app-python. Names can use letters and digits only, and MazeVPN adds the app- prefix.
  2. On that card, click Copy next to HTTPS proxy (marked Encrypted). The copied URL contains the password, so paste it only into a secret or environment variable, never into code.
    MazeVPN client area: the card of proxy user app-ci with its HTTPS, HTTP and SOCKS5 proxy URLs and Copy buttons
    The card of a new proxy user. The eye icon shows the password; Copy copies the full URL with the password. (Server IP replaced with an example.)
    You should see: a URL like https://app-python:…@203.0.113.42:443, where the address is your server’s IP.
  3. Install both clients and the optional Requests SOCKS dependency. Set MAZE_PROXY_URL in your secret store to a URL in the example format.
    python -m pip install "requests[socks]" httpx
    You should see: Both clients import successfully. The HTTPS proxy URL has the form https://app-python:PASSWORD@203.0.113.42:443.

Requests: compare explicit, session, and environment settings

In a November 24, 2026 test in WSL, the direct Requests call returned the machine’s IPv4. The explicit, session, and environment settings, both HTTPX clients, and Requests over SOCKS5 all returned the QA server’s IPv4.

Keep the destination URL HTTPS. The scheme of the proxy URL describes the connection to the proxy itself. Set both dictionary keys when both HTTP and HTTPS destinations should use the same proxy.

Per Requests docs, environment settings can override Session.proxies. Set trust_env=False on a session when you want to isolate it from machine-wide settings. This also turns off other environment-derived settings, so configure any custom certificate bundle explicitly.

import os
import requests

url = "https://api.ipify.org"
p = os.environ["MAZE_PROXY_URL"]
proxies = {"http": p, "https": p}

def show(label, response):
    response.raise_for_status()
    print(label, response.text.strip())

with requests.Session() as s:
    s.trust_env = False
    show("direct", s.get(url, timeout=(5, 15)))
    show("explicit", s.get(url, proxies=proxies, timeout=(5, 15)))
    s.proxies.update(proxies)
    show("session", s.get(url, timeout=(5, 15)))

os.environ["HTTPS_PROXY"] = p
show("environment", requests.get(url, timeout=(5, 15)))
Use a clean shell for the environment check. Check for an existing lowercase https_proxy or a NO_PROXY rule matching the test host.

HTTPX: sync and async

Reuse a Client or AsyncClient for multiple requests. A timeout limits time spent waiting on the network. HTTPX supports separate connect, read, write, and pool timeouts when you need finer control.

import asyncio
import os
import httpx

url = "https://api.ipify.org"
p = os.environ["MAZE_PROXY_URL"]
timeout = httpx.Timeout(15.0, connect=5.0)

with httpx.Client(proxy=p, trust_env=False, timeout=timeout) as client:
    r = client.get(url)
    r.raise_for_status()
    print("sync", r.text.strip())

async def main():
    async with httpx.AsyncClient(proxy=p, trust_env=False, timeout=timeout) as client:
        r = await client.get(url)
        r.raise_for_status()
        print("async", r.text.strip())

asyncio.run(main())

Requests: SOCKS5 with proxy-side DNS

For a tool that requires SOCKS5, set MAZE_SOCKS_URL to socks5h://app-python:PASSWORD@203.0.113.42:1080. The socks5h scheme asks the proxy to resolve the hostname. SOCKS5 does not add TLS to the client-to-proxy link. Prefer the HTTPS proxy for HTTP clients that support it.

import os
import requests

p = os.environ["MAZE_SOCKS_URL"]
with requests.Session() as s:
    s.trust_env = False
    r = s.get("https://api.ipify.org", proxies={"http": p, "https": p}, timeout=(5, 15))
    r.raise_for_status()
    print(r.text.strip())

Official references

Skip the setup

A dedicated IPv4 in 38 cities, usually ready about 3 minutes after payment. Connect devices with WireGuard and apps with an authenticated HTTPS, HTTP, or SOCKS5 proxy. From $9.99/month.

FAQ

Questions, answered.

Something else? Open a ticket, a human replies.

Why does HTTPS_PROXY appear to be ignored? +

Check trust_env, lowercase variables, and NO_PROXY. Compare the response with the IPv4 in your service panel.

Does calling an HTTPS URL encrypt the proxy password? +

Use an HTTPS proxy URL to encrypt the connection from your client to the proxy, including authentication.

Do I need an extra dependency for SOCKS5? +

Install Requests with its socks extra for the SOCKS5 sample.

Can I use my own VPS? +

Yes. Run an authenticated proxy on a server with stable egress and configure a certificate trusted by your clients.

What does MazeVPN cost for this? +

Solo is $9.99 a month with one dedicated IPv4 and three proxy users. See the pricing page.

More guides