How to Configure Proxy on Ubuntu & Debian Linux

Updated:

On Ubuntu and Debian Linux, proxy settings are scoped by execution context: shell sessions read /etc/environment or ~/.bashrc, the APT package manager reads /etc/apt/apt.conf.d/, systemd services read drop-in unit files, and GNOME Desktop uses gsettings. This guide provides exact configuration snippets for every Ubuntu subsystem using VinaProxy HTTP(S) proxies.

Ubuntu / Linux · HTTP Proxy Format
export http_proxy=http://user:pass@ip:port https_proxy=http://user:pass@ip:port
Private IPv4 (datacenter)
🇺🇸 United States
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United States
Private IPv4 (datacenter)
🇸🇬 Singapore
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy Singapore

Ubuntu Proxy Configuration Scopes

sudo strips user environment variables by default, and systemd services do not read ~/.bashrc. Use this reference table to configure the right file on Ubuntu:

Ubuntu SubsystemConfig File / CommandApplies ToPersistence
Interactive Shell~/.bashrc or /etc/profile.d/proxy.shcurl, wget, python, git, nodeEvery login shell
System-Wide PAM Env/etc/environmentAll PAM user sessionsAcross reboots
APT Package Manager/etc/apt/apt.conf.d/80proxysudo apt update & apt installPermanent for APT
systemd Services/etc/systemd/system/<svc>.service.d/proxy.confDocker daemon, custom servicesAfter daemon-reload

Step-by-Step Setup on Ubuntu Server & Desktop

bash # 1. /etc/profile.d/proxy.sh (Shell & CLI tools) sudo tee /etc/profile.d/proxy.sh > /dev/null << 'EOF' export http_proxy="http://USER:PASS@IP:PORT" export https_proxy="http://USER:PASS@IP:PORT" export HTTP_PROXY="http://USER:PASS@IP:PORT" export HTTPS_PROXY="http://USER:PASS@IP:PORT" export no_proxy="localhost,127.0.0.1,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" export NO_PROXY="$no_proxy" EOF source /etc/profile.d/proxy.sh # 2. /etc/apt/apt.conf.d/80proxy (APT package manager) sudo tee /etc/apt/apt.conf.d/80proxy > /dev/null << 'EOF' Acquire::http::Proxy "http://USER:PASS@IP:PORT/"; Acquire::https::Proxy "http://USER:PASS@IP:PORT/"; EOF

Preserving Proxy Variables Under sudo & Special Characters

  • If you run commands via sudo curl ... or sudo pip ..., pass sudo -E to preserve your exported proxy environment variables, or add Defaults env_keep += "http_proxy https_proxy HTTP_PROXY HTTPS_PROXY no_proxy NO_PROXY" via sudo visudo.
  • Restrict file permissions (sudo chmod 600 /etc/apt/apt.conf.d/80proxy) on shared multi-user Linux servers so other local users cannot read your proxy credentials.

Step by step

  1. 1

    Export Shell Environment Variables (/etc/profile.d/proxy.sh)

    Create /etc/profile.d/proxy.sh defining both lowercase (http_proxy, https_proxy, no_proxy) and uppercase (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) variables so all GNU and Go/Rust CLI tools recognize them.

  2. 2

    Configure APT Package Manager Proxy

    Because sudo apt update ignores user shell variables, create /etc/apt/apt.conf.d/80proxy with Acquire::http::Proxy and Acquire::https::Proxy.

  3. 3

    Test Outbound Connectivity with curl

    Source your profile (source /etc/profile.d/proxy.sh) and run curl -s https://api.ipify.org to verify your Ubuntu machine routes through VinaProxy.

Frequently asked questions

Why do I need both lowercase http_proxy and uppercase HTTP_PROXY on Linux?

Some Linux tools (like curl and wget) check lowercase http_proxy, while others works only with uppercase HTTP_PROXY (or both). Defining both guarantees consistent behavior across all runtimes.

Why does `sudo apt update` ignore my exported `http_proxy` variable?

sudo resets environment variables for security unless invoked with sudo -E. Configuring /etc/apt/apt.conf.d/80proxy ensures APT always uses the proxy cleanly.

How do I configure a proxy on Ubuntu Desktop GUI (GNOME)?

Open Settings → Network → Network Proxy → Manual, or use gsettings set org.gnome.system.proxy mode 'manual' along with org.gnome.system.proxy.http host and port.

Get low-latency HTTP(S) proxies for Ubuntu

Instant Dedicated IPv4 and Static ISP credentials across 7 countries.

View Proxy Pricing

Related articles

Proxy setup
How to set up a proxy in Docker (Containers, Compose & Builds)
Route Docker containers and Docker Compose services through authenticated HTTP(S) proxies using HTTP_PROXY, HTTPS_PROXY, and NO_PROXY.
Proxy setup
How to use a proxy with cURL (command-line syntax & debugging)
How to use curl with authenticated HTTP(S) proxies (-x http://user:pass@ip:port and -U) on Linux, macOS, and Windows.
Proxy setup
How to use a proxy in Python Requests (HTTP/HTTPS & Session pooling)
Configure authenticated HTTP(S) proxies in Python requests and requests.Session(). Handle 407 ProxyError exceptions and rotate static IP pools.
Free tools
Proxy Checker: Check Your Proxies Online
Free proxy checker: paste up to 100 proxies as ip:port:user:pass and check proxy online for status, exit IP and latency. Learn what each error means.
Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxies by platform
Proxies for Airdrops & DePIN (Grass): prevent Sybil flags with dedicated Static ISP IPs
Farm Web3 airdrops, testnets, and DePIN browser nodes (Grass, Dawn, Nodepay) safely. Dedicated Static ISP and private IPv4 proxies.
Proxies by platform
Proxies for SEO & SERP Tracking: accurate keyword rankings across 7 countries
Track localized keyword rankings, audit geo-redirects, and run Screaming Frog crawls with unmetered dedicated IPv4 and Static ISP proxies.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.