Docs menu
Docs

Set a Proxy From the Command Line

To use a proxy from the command line on Linux or macOS, set the proxy environment variables, export https_proxy="http://<login>:<password>@host:port" and its siblings, and tools that read them (curl, wget, git, pip, Python requests and Go programs) send their traffic through it; for SOCKS5, export ALL_PROXY="socks5h://<login>:<password>@host:port". apt, git and npm can also take their own setting. In Windows, set or setx does the same in Command Prompt, PowerShell's Invoke-WebRequest takes a -Proxy parameter, and netsh winhttp sets the proxy for system services. With ProxyField, every one of these points at gate.proxyfield.io:7000, residential proxies cost from $1.95/GB, and the Easy Trial is 1 GB for $2.95.

residential IPs
412M+
from, traffic never expires
$1.95/GB
Easy Trial
1 GB for $2.95
gate.proxyfield.io:7000
ProxyField values for the command line
Command-line settingProxyField value
http_proxy, https_proxy, HTTPS_PROXYhttp://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000, also for https:// sites
ALL_PROXY (SOCKS5)socks5h:// with the same username and password, so the gateway resolves the site's name
Host and portgate.proxyfield.io, 7000: HTTP, HTTPS and SOCKS5 all run on the same host and port
Username<login>-country-us-city-new_york; the optional keys are -country-<cc>, -region-<region>, -city-<city>, -session-<id> and -ttl-<seconds> (30 to 129,600 s, 20 min when ttl is left out); add -mobile or -dc right after the login for mobile or rotating datacenter IPs (-dc takes the country only)
Passwordyour ProxyField password; percent-encode @, :, / and # in a URL
No password in the URLadd your IP to the allowlist (up to 100 IPv4 addresses) and use gate.proxyfield.io with the port you set up in the dashboard
PowerShell-Proxy "http://gate.proxyfield.io:7000" with -ProxyCredential; a login written into -Proxy is not sent
netsh winhttptakes no login: use it with the allowlist and the port you set up in the dashboard
IP behavioura new IP on every request, or one IP for 30 s to 36 h with -session-<id>-ttl-<seconds>
Parallel commandsunlimited concurrent threads, so one exported variable serves many commands at once
Headersthe gateway adds no Via, X-Forwarded-For or Forwarded header; the headers curl, wget or your program sends pass through; your Proxy-Authorization is removed before the request goes to the site

Set a proxy from the command line with ProxyField

  1. Export http_proxy, https_proxy and HTTPS_PROXY with the proxy URL from the table.
  2. Set no_proxy and NO_PROXY for local hosts such as localhost,127.0.0.1.
  3. For SOCKS5, export ALL_PROXY with socks5h:// and unset the HTTP variables, which win over it.
  4. Add the lines to ~/.zshrc or ~/.bashrc to keep them, and source the file.
  5. Run curl https://api.ipify.org: it prints the proxy's exit IP, not yours.

The HTTP form in Bash or zsh, then one request that uses it.

Shell
export https_proxy="http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000"
curl https://api.ipify.org

curl's own rules for these variables are in its manual's ENVIRONMENT section: curl man page (curl project).

On this page 9 sections

Set proxy environment variables on Linux and macOS

Set the variables in your shell, then run your commands as usual:

Shell
export http_proxy="http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000"
export https_proxy="$http_proxy"
export HTTPS_PROXY="$http_proxy"
export no_proxy="localhost,127.0.0.1,::1,.local"
export NO_PROXY="$no_proxy"

curl https://api.ipify.org   # prints the proxy's exit IP, not yours

SOCKS5 instead of HTTP. ProxyField serves SOCKS5 on the same host and port, with the same login:

Shell
export ALL_PROXY="socks5h://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000"
export all_proxy="$ALL_PROXY"

curl https://api.ipify.org   # curl uses ALL_PROXY when no protocol-specific variable is set
  • socks5h:// resolves the site's hostname through the proxy; socks5:// resolves it on your machine, so your DNS lookups stay local. Use socks5h:// unless you have a reason not to; more in SOCKS5 vs HTTP proxy.
  • A protocol-specific variable beats ALL_PROXY: if https_proxy is also set, curl uses it for https:// sites and ignores ALL_PROXY. Unset the HTTP variables when you switch to SOCKS.
  • Not every tool speaks SOCKS: curl does, wget does not, and Python requests needs the SOCKS extra (pip install "requests[socks]").

Which variable a tool reads depends on the tool:

VariableWhat it coversNotes
http_proxyrequests to http:// sitescurl reads only the lowercase name for HTTP, as protection against the "httpoxy" header attack
https_proxy / HTTPS_PROXYrequests to https:// sitesmost tools read either case
all_proxy / ALL_PROXYevery protocol without its own variableoften used for SOCKS: socks5h://<login>:<password>@host:port
no_proxy / NO_PROXYhosts that skip the proxycomma-separated; .example.com covers subdomains; * alone skips the proxy for every host

Setting both cases avoids surprises; where both are set, curl checks the lowercase name first. The curl rules are in its manual's ENVIRONMENT section (curl man page).

Which tools read them. curl, wget, git, pip, Python requests and Go's default HTTP client read the proxy variables. Node.js's built-in http module and fetch do not by default: a Node.js program needs a proxy agent or its own proxy setting.

Run one command through a proxy without exporting anything:

Shell
https_proxy="http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000" curl https://api.ipify.org

For programs that ignore the variables entirely, proxychains-style wrappers force their connections through a proxy; see the Linux proxy setup guide.

Make the variables permanent on Linux and macOS

The variables live only in the current shell. To keep them, add the export lines to your shell's startup file:

SystemDefault shellFileReload
macOS (Catalina and later)zsh~/.zshrcsource ~/.zshrc
Linux, interactive Bashbash~/.bashrcsource ~/.bashrc
Linux, login shells (SSH, console)bash or sh~/.profile (or ~/.bash_profile)log in again
Linux, every userany/etc/environment (plain NAME=value lines, no export)log in again

Terminal windows that were already open do not see the change until you source the file in them. The password is now stored in that file, so keep it readable only by you (chmod 600 ~/.zshrc), or use the IP allowlist instead of a password in the URL. Mac-wide settings for apps other than the terminal: macOS proxy setup.

sudo usually drops them. On most distributions sudo resets the environment, so sudo apt update ignores your exports unless the sudoers file keeps the proxy variables. Use sudo -E to keep them for one command, or give apt its own setting (below).

Set a proxy for apt

apt reads its proxy from a file in /etc/apt/apt.conf.d/, so it works under sudo:

Shell
sudo tee /etc/apt/apt.conf.d/95proxy >/dev/null <<'EOF'
Acquire::http::Proxy "http://<login>:<password>@gate.proxyfield.io:7000/";
Acquire::https::Proxy "http://<login>:<password>@gate.proxyfield.io:7000/";
EOF
sudo apt update

The Acquire::http::Proxy option is described in the apt-transport-http manual. Delete the file to stop. Package downloads are large, and every byte through a residential proxy counts as traffic, so route apt through a proxy only when the network requires it.

Tools with their own proxy settings

ToolCommandUndo
gitgit config --global http.proxy http://<login>:<password>@gate.proxyfield.io:7000git config --global --unset http.proxy
npmnpm config set proxy http://<login>:<password>@gate.proxyfield.io:7000 and npm config set https-proxy <same URL>npm config delete proxy, npm config delete https-proxy
pippip install --proxy http://<login>:<password>@gate.proxyfield.io:7000 <package>omit the flag
wgetreads http_proxy and https_proxy; -e use_proxy=yes -e https_proxy=<URL> for one runwget guide
curl-x <URL> for one request, --noproxy '*' to skip the proxycurl guide

Special characters in the password (@, :, /, #) must be percent-encoded in these URLs; proxy format shows how.

Set a proxy in Windows Command Prompt

Windows cmd
:: this window only
set HTTPS_PROXY=http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000
set HTTP_PROXY=%HTTPS_PROXY%
curl https://api.ipify.org

:: saved for new windows (setx does not change the current one)
setx HTTPS_PROXY "http://<login>-country-us-city-new_york:<password>@gate.proxyfield.io:7000"

curl.exe, Python, Git and pip read these variables; Node.js does not by default. Windows itself does not: the system proxy is set in Settings, and the proxy for Windows services is set with netsh winhttp, which takes no login, so pair it with ProxyField's IP allowlist and use the port you set up in the dashboard as <port>:

Windows cmd
netsh winhttp set proxy proxy-server="gate.proxyfield.io:<port>" bypass-list="<local>"
netsh winhttp show proxy
netsh winhttp reset proxy

The command reference is on Microsoft Learn: netsh winhttp. The Windows proxy setup guide covers the Settings side and setting a proxy from the Command Prompt step by step.

Set a proxy in PowerShell

Invoke-WebRequest and Invoke-RestMethod take the proxy and its login as parameters. Build the credential from environment variables instead of typing the password into the script:

PowerShell
$pass = ConvertTo-SecureString $env:PROXY_PASS -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($env:PROXY_USER, $pass)
Invoke-RestMethod -Uri "https://api.ipify.org" -Proxy "http://gate.proxyfield.io:7000" -ProxyCredential $cred

$env:PROXY_USER holds a username such as <login>-country-us-city-new_york. In PowerShell 7, $env:HTTPS_PROXY = "http://<login>:<password>@gate.proxyfield.io:7000" also works for these cmdlets, because .NET reads the proxy variables (Microsoft Learn: HttpClient.DefaultProxy). To make every Invoke-WebRequest in a session use the authenticated proxy, set it once as a default parameter value: $PSDefaultParameterValues["Invoke-WebRequest:Proxy"] = "http://gate.proxyfield.io:7000" and $PSDefaultParameterValues["Invoke-WebRequest:ProxyCredential"] = $cred, with the same two lines for Invoke-RestMethod (Microsoft Learn: about_Parameters_Default_Values); the other session-wide options are on PowerShell proxy setup.

Can you ping through a proxy?

No. ping sends ICMP packets, and HTTP and SOCKS proxies relay TCP connections (SOCKS5 also UDP), not ICMP, so ping always goes out directly from your machine. To test a proxy from the command line, make a real request through it and time it:

Shell
curl -x gate.proxyfield.io:7000 -U "<login>-country-us-city-new_york:<password>" \
  -o /dev/null -s -w "connect %{time_connect}s, total %{time_total}s, HTTP %{http_code}\n" \
  https://api.ipify.org

time_connect is the time to reach the proxy, and time_total includes the trip through the exit IP to the site. Run it a few times; a residential exit adds the latency of a home connection.

Check that the command line uses the proxy

  • curl https://api.ipify.org prints the exit IP. It differs from your own when the proxy is in use.
  • curl -v https://api.ipify.org 2>&1 | grep -i proxy shows whether curl picked up a proxy variable.
  • env | grep -i _proxy lists what is set.

To switch everything off again, see how to turn off a proxy. ProxyField proxies run on HTTP, HTTPS and SOCKS5 with unlimited concurrent threads, so one exported variable can serve many parallel commands; proxy authentication covers using the IP allowlist instead of a password in the URL.

Set a Proxy From the Command Line FAQ

How do I set an HTTP or SOCKS5 proxy with environment variables for terminal commands on Linux and macOS?

ProxyField serves HTTP and SOCKS5 on the same gateway, gate.proxyfield.io:7000, so the two forms are export https_proxy="http://<login>:<password>@gate.proxyfield.io:7000" (with http_proxy set to the same value) and export ALL_PROXY="socks5h://<login>:<password>@gate.proxyfield.io:7000". The syntax is the same in Bash on Linux and zsh on macOS; add the lines to ~/.bashrc or ~/.zshrc to keep them, and run source on the file. A protocol-specific variable beats ALL_PROXY, and socks5h:// sends DNS lookups through the proxy too; residential traffic costs from $1.95/GB.

What is the command to set up an HTTP proxy?

ProxyField residential proxies cost from $1.95/GB, and the command to set up an HTTP proxy for them on Linux and macOS is export https_proxy="http://<login>:<password>@gate.proxyfield.io:7000" (plus http_proxy with the same value). In Windows Command Prompt it is set HTTPS_PROXY= with the same URL. Tools that read these variables, such as curl, wget, git, pip and Python requests, then send every request through the gateway.

Can I ping through a proxy?

No. ping uses ICMP, and HTTP and SOCKS proxies relay TCP connections, so ping always goes out directly. To test a proxy, time a real request through it with curl's -w "%{time_connect} %{time_total}".

How do I enable an HTTP proxy?

For the whole device, enter the server and port in the system proxy settings; for command-line tools, set the http_proxy and https_proxy variables; for one program, use its own proxy option. Each covers only the apps that read it.

How do I set a proxy for an installer?

Give the installer its own setting: an Acquire::http::Proxy line in /etc/apt/apt.conf.d/ for apt, --proxy for pip, npm config set proxy for npm. Graphical installers on Windows and macOS usually follow the system proxy.

What does "proxy from env" mean?

It means a program takes its proxy from the environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) instead of its own settings. Go's http.ProxyFromEnvironment and the default behavior of Python requests are examples.

How do I set a SOCKS5 proxy environment variable?

Use ALL_PROXY (or all_proxy) with a SOCKS URL, for example export ALL_PROXY="socks5h://<login>:<password>@gate.proxyfield.io:7000", and unset http_proxy and https_proxy, which would win over it. curl honors it; wget has no SOCKS support, and Python requests needs requests[socks] installed.

What's the difference between HTTP_PROXY and HTTPS_PROXY?

HTTP_PROXY is used for requests to http:// addresses and HTTPS_PROXY for https:// addresses; the names describe the target site, not the proxy. Both usually hold the same http:// proxy URL.

Should a proxy username and password be placed inside HTTP_PROXY?

It works, and it is the usual way for command-line tools, but the password is then visible to anything that can read your environment or shell profile. On shared machines and CI systems, prefer a secret store, or an IP allowlist so the URL needs no password.

Does netsh winhttp change my browser's proxy?

No. netsh winhttp sets the proxy for Windows services that use WinHTTP; browsers use the per-user proxy from Settings > Network & internet > Proxy. Change that one for Chrome and Edge.

Show 2 more questionsShow fewer questions

Do environment variables apply to all terminal commands?

Only to commands started from that shell after you set them, and only to programs that read them. sudo usually drops them unless you use sudo -E, and some programs, such as Node.js's built-in fetch, ignore them by default.

Does Go read HTTP_PROXY and HTTPS_PROXY automatically?

Yes. Go's default HTTP transport uses http.ProxyFromEnvironment, which reads HTTP_PROXY, HTTPS_PROXY and NO_PROXY in upper or lower case. A custom transport needs its Proxy field set to do the same.

Easy Trial: 1 GB for $2.95.

Try for the price of 1 GB, no subscription, traffic never expires.