Published 2026-10-06

How to use a proxy with curl and Python

The same four values work in every tool: host, port, username and password. Here is the shape in curl and in Python.

What you need

From your dashboard, copy the proxy host, the port, your username and your password. Replace HOST, PORT, USER and PASS below with them.

curl

curl --proxy http://USER:PASS@HOST:PORT https://api.ipify.org

The response is the IP address the target sees. If it is your own address, the proxy is not being used.

Python requests

import requests
proxy = "http://USER:PASS@HOST:PORT"
response = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=15)
print(response.text)

Always set a timeout. A request without one can hang for a long time on a bad proxy.

SOCKS5

curl --proxy socks5h://USER:PASS@HOST:PORT https://api.ipify.org

In Python, install the SOCKS extra with pip install "requests[socks]" and use a socks5h:// URL in the same dictionary. See SOCKS5 vs HTTP.

When it does not work

A 407 means the proxy rejected your credentials. A refused connection usually means the wrong host or port. Your own IP in the answer means the proxy was bypassed. The ten-minute test walks through all of these.

Frequently asked questions

Why does curl need the h in socks5h?

The h makes the proxy resolve the hostname. Without it, your machine resolves it and may leak the lookup.

Should I put credentials in the URL?

It is the simplest form. In shared environments, read them from environment variables instead of writing them in code.

Try it for $5

Minimum top-up is $5. Run your own target through it before you scale.

Create account