How to Set Up a Proxy on Ubuntu Linux (GUI and Terminal Methods)

How to Set Up a Proxy on Ubuntu Linux (GUI and Terminal Methods)

Linux is the operating system of choice for many developers, system administrators, and data professionals who rely on proxies for web scraping, network testing, and privacy. Ubuntu, as the most popular Linux distribution, offers multiple ways to configure proxy settings — from a graphical interface to terminal commands and configuration files.

This guide covers every method for setting up proxies on Ubuntu Linux, including system-wide configuration, per-application settings, and persistent configurations that survive reboots.

Why Use a Proxy on Linux

Linux systems are frequently used for tasks that benefit from proxy routing:

  • Automated web scraping — Linux servers often run scrapers that require IP rotation. See our web scraping proxy guide for detailed strategies.
  • Package manager access — Some networks require proxies for apt, pip, or npm to reach external repositories.
  • Server administration — Route outbound traffic through a proxy for security auditing.
  • Development and testing — Test applications with different IP addresses and locations.
  • Privacy — Hide your server’s real IP when making outbound requests.

Method 1: Configure a Proxy via Ubuntu GUI (GNOME Settings)

Ubuntu’s default GNOME desktop includes a graphical proxy configuration tool.

Step 1: Open Network Settings

  1. Click the system menu in the top-right corner of the screen.
  2. Click the gear icon to open Settings.
  3. Click Network in the left sidebar.

Step 2: Configure Proxy

  1. Click the gear icon next to Network Proxy.
  2. Change the method from None to Manual.
  3. Enter your proxy details:
ProtocolHostPort
HTTP Proxyproxy.example.com8080
HTTPS Proxyproxy.example.com8443
SOCKS Hostproxy.example.com1080
  1. In the Ignore Hosts field, add addresses that should bypass the proxy: localhost, 127.0.0.0/8, ::1

Step 3: Apply and Verify

The settings apply immediately for GNOME-integrated applications. Open Firefox and visit whatismyipaddress.com to verify.

Note: GNOME proxy settings only affect applications that use the GSettings/dconf system. Many CLI tools and servers ignore these settings.

Method 2: Set Environment Variables (Terminal)

Environment variables are the most common way to configure proxies for command-line tools on Linux.

Temporary (Current Session Only)

export http_proxy="http://username:password@proxy.example.com:8080"
export https_proxy="http://username:password@proxy.example.com:8080"
export ftp_proxy="http://username:password@proxy.example.com:8080"
export no_proxy="localhost,127.0.0.1,::1,.local"

# Some tools check uppercase versions
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"
export NO_PROXY="$no_proxy"

Permanent (Current User)

Add the export commands to your shell profile:

# For bash users
nano ~/.bashrc

# For zsh users
nano ~/.zshrc

Add the following lines at the end of the file:

export http_proxy="http://proxy.example.com:8080"
export https_proxy="http://proxy.example.com:8080"
export no_proxy="localhost,127.0.0.1,.local"

Reload the profile:

source ~/.bashrc  # or source ~/.zshrc

System-Wide (All Users)

Create a proxy configuration file that applies to all users:

sudo nano /etc/profile.d/proxy.sh

Add:

export http_proxy="http://proxy.example.com:8080"
export https_proxy="http://proxy.example.com:8080"
export no_proxy="localhost,127.0.0.1,.local"

Make it executable:

sudo chmod +x /etc/profile.d/proxy.sh

This takes effect on the next login for all users.

Method 3: Configure Proxy for APT Package Manager

Ubuntu’s APT package manager has its own proxy configuration that is separate from environment variables.

Temporary (Single Command)

sudo apt -o Acquire::http::Proxy="http://proxy.example.com:8080" update

Permanent APT Proxy Configuration

Create a dedicated configuration file:

sudo nano /etc/apt/apt.conf.d/95proxies

Add the following:

Acquire::http::Proxy "http://username:password@proxy.example.com:8080";
Acquire::https::Proxy "http://username:password@proxy.example.com:8443";
Acquire::ftp::Proxy "http://username:password@proxy.example.com:8080";

Save the file. APT will use these proxy settings for all future operations.

Verify APT Proxy

sudo apt update

If the update completes successfully and downloads package lists, your proxy is working.

Method 4: Configure Proxy Using gsettings (GNOME CLI)

You can set GNOME proxy settings from the terminal using gsettings:

# Set proxy mode to manual
gsettings set org.gnome.system.proxy mode 'manual'

# Configure HTTP proxy
gsettings set org.gnome.system.proxy.http host 'proxy.example.com'
gsettings set org.gnome.system.proxy.http port 8080

# Configure HTTPS proxy
gsettings set org.gnome.system.proxy.https host 'proxy.example.com'
gsettings set org.gnome.system.proxy.https port 8443

# Configure SOCKS proxy
gsettings set org.gnome.system.proxy.socks host 'proxy.example.com'
gsettings set org.gnome.system.proxy.socks port 1080

# Set authentication (HTTP)
gsettings set org.gnome.system.proxy.http authentication-user 'username'
gsettings set org.gnome.system.proxy.http authentication-password 'password'
gsettings set org.gnome.system.proxy.http use-authentication true

# Set ignore hosts
gsettings set org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '::1']"

Disable Proxy via gsettings

gsettings set org.gnome.system.proxy mode 'none'

Method 5: Configure SOCKS5 Proxy with SSH Tunnel

If you have SSH access to a remote server, you can create a SOCKS5 proxy tunnel without any additional software:

ssh -D 1080 -f -C -q -N user@remote-server.com

Flags explained:

  • -D 1080 — Creates a SOCKS proxy on local port 1080
  • -f — Runs in the background
  • -C — Enables compression
  • -q — Quiet mode
  • -N — No remote command execution

Then configure applications to use 127.0.0.1:1080 as a SOCKS5 proxy.

Use the SSH Tunnel with curl

curl --socks5 127.0.0.1:1080 https://api.ipify.org

Method 6: Configure Proxy in /etc/environment

The /etc/environment file provides system-wide environment variables that affect all users and services:

sudo nano /etc/environment

Add:

http_proxy="http://proxy.example.com:8080"
https_proxy="http://proxy.example.com:8080"
no_proxy="localhost,127.0.0.1,.local"

Important: This file does not support export syntax — just use key="value" format.

Reboot or log out and back in for changes to take effect.

Configuring Proxy for Specific Linux Tools

wget

Create or edit ~/.wgetrc:

http_proxy = http://proxy.example.com:8080
https_proxy = http://proxy.example.com:8080
use_proxy = on

curl

Create or edit ~/.curlrc:

proxy = http://proxy.example.com:8080

pip (Python)

pip install package-name --proxy http://proxy.example.com:8080

Or permanently in ~/.config/pip/pip.conf:

[global]
proxy = http://proxy.example.com:8080

snap

sudo snap set system proxy.http="http://proxy.example.com:8080"
sudo snap set system proxy.https="http://proxy.example.com:8080"

Troubleshooting Linux Proxy Issues

Proxy Works in Terminal but Not in GUI Apps

GUI applications often use GNOME/dconf settings rather than environment variables. Configure the proxy in both places for full coverage.

sudo Commands Do Not Use Proxy

By default, sudo resets environment variables. Preserve them with:

sudo -E apt update

Or configure sudoers to keep proxy variables:

sudo visudo

Add:

Defaults env_keep += "http_proxy https_proxy no_proxy"

Connection Refused Errors

  1. Verify the proxy server is reachable: telnet proxy.example.com 8080
  2. Check for firewall rules blocking outbound connections: sudo iptables -L
  3. Ensure the proxy credentials are correct

Slow Downloads Through Proxy

Free proxies are often heavily congested. A premium mobile proxy service provides dedicated bandwidth and consistent speeds. For definitions of proxy terminology you encounter, our proxy glossary is a helpful reference.

Quick Reference: Proxy Configuration Cheat Sheet

MethodScopePersistentCLI ToolsGUI Apps
Environment variablesSession/UserOptionalYesNo
/etc/environmentSystemYesYesPartial
GNOME SettingsDesktopYesNoYes
gsettingsDesktopYesNoYes
apt.confAPT onlyYesAPT onlyNo
/etc/profile.d/All usersYesYesNo

Conclusion

Ubuntu Linux provides extensive proxy configuration options to suit every use case. For most desktop users, combining GNOME settings with environment variables provides comprehensive coverage. Server administrators should focus on /etc/environment and application-specific configurations like apt.conf. Whichever method you choose, always verify your setup by checking your public IP and testing the specific tools you need to route through the proxy.


Related Reading

Scroll to Top