# curl Proxy: HTTP, SOCKS5 and Env Variables | ProxyJam

Send curl through an HTTP or SOCKS5 proxy with -x and -U, set it with environment variables and encode special characters in the password.

- Canonical: https://proxyjam.com/faq/curl-proxy/
- Updated: 2026-11-22
- Language: en

Use curl -x http://HOST:PORT -U LOGIN:PASSWORD URL for an HTTP proxy, and socks5h://HOST:PORT for SOCKS5. The -U option takes the password as typed. Set http_proxy, https_proxy or all_proxy to cover a whole shell, and percent-encode special characters when the login sits inside the URL.


## Quick answers about curl and proxies

### Why socks5h and not socks5?

With socks5h curl sends the host name to the proxy to resolve; with socks5 curl resolves it locally first. Use socks5h unless you need the local lookup.

### Do I keep http:// in the proxy address for HTTPS sites?

Yes. The scheme describes how curl talks to the proxy, not the site. An HTTP proxy carries HTTPS pages through a tunnel.

### What does a 407 from curl mean?

The proxy rejected the login or your address. Recopy the details from the dashboard and check the allowlist.



curl is the quickest way to test a proxy, and it works the same on macOS, Linux and
Windows. Replace the four placeholders with the values of one row in **My Proxies** in
your [dashboard](https://app.proxyjam.com).

## HTTP proxy

```
curl -x http://HOST:PORT -U LOGIN:PASSWORD https://example.com/
```

`-x` (long form `--proxy`) sets the proxy and `-U` (`--proxy-user`) sets the login. The
password in `-U` is taken as typed, so it needs no encoding there. Keep `http://` in the
proxy address even when the page uses HTTPS: the scheme names how curl talks to the
proxy. Add `-I` to print only the headers, or `-v` to watch the tunnel open.

## SOCKS5 proxy

Switch the order with **Change protocol** first and copy the details again. Then:

```
curl -x socks5h://HOST:PORT -U LOGIN:PASSWORD https://example.com/
```

The `h` makes the proxy resolve the host name. The older `--socks5-hostname HOST:PORT`
option does the same. Our [SOCKS5 proxies](/socks5-proxies/) page describes the protocol.

## Credentials inside the URL

You can write the login into the proxy address instead:

```
curl -x http://LOGIN:PASSWORD@HOST:PORT https://example.com/
```

Characters with a meaning in a URL must then be percent-encoded: `@` becomes `%40`, `:`
becomes `%3A`, `/` becomes `%2F`, `#` becomes `%23` and `%` becomes `%25`. A password that
is not encoded is cut at the first such character, and the proxy answers 407.

## Environment variables

To cover every curl command in the current shell:

```
export http_proxy="http://LOGIN:PASSWORD@HOST:PORT"
export https_proxy="http://LOGIN:PASSWORD@HOST:PORT"
```

In PowerShell the same looks like this:

```
$env:http_proxy = "http://LOGIN:PASSWORD@HOST:PORT"
$env:https_proxy = "http://LOGIN:PASSWORD@HOST:PORT"
```

Quote the value, and a password with shell-special characters such as `$`, `&` or `!` needs
quoting or escaping as well; single quotes are safest in a POSIX shell.

`all_proxy` sets one proxy for every protocol, and `no_proxy` lists hosts that skip it.
Use the lowercase names for `http_proxy`, because curl ignores the uppercase form for
plain HTTP. Remove them with `unset http_proxy https_proxy`. The details are visible in
your shell history and in the process list, so do not use this on a shared machine.

## Which form to use

Use `-x` and `-U` for a single request and for scripts, because they leave your shell
untouched. Use the URL form when a tool takes only one proxy string. Use the environment
variables when you work in a shell for a while and want every curl call to follow the same
route. In a script, prefer variables set inside the script over ones exported globally.

## Read the result

A `200` or a redirect means the proxy accepted the sign-in. A `407` means it did not:
[proxy error 407](/faq/proxy-error-407/) lists the checks, and
[proxy authentication failed](/faq/proxy-authentication-failed/) covers the allowlist mode.
To confirm the exit address, load [What Is My IP](/what-is-my-ip/) through the proxy, or paste
the proxy into our [proxy checker](/proxy-checker/), which runs the same one-request test without a
terminal. The
same proxy in code is on the [Python requests](/integrations/python-requests/) page, and
orders and prices are on the [ISP proxies](/isp-proxies/) page.

