How to Set System Wide Proxy in Ubuntu 18.04


In this guide, we are going to learn how to set system wide proxy in Ubuntu 18.04. Imagine you are in a local network environment where access to the Internet is also possible when you are going through a proxy server. Well, in this guide we are gonna learn how to configure system wide proxy settings on your Ubuntu 18.04 server or desktop so that you can be able to access the Internet.

Set System Wide Proxy in Ubuntu 18.04

To set system wide proxy in Ubuntu 18.04 is a pretty straightforward task. Let us see how.

Set System Wide Proxy using Environment Variables

One of the ways of configuring system wide proxy settings on Ubuntu 18.04 system is by using environment variables especially if you are running an headless server. Proxy environment variables depend on the protocol handlers used by your proxy server. This can either be http, https, ftp or socks.

Hence to set http or https proxy environment variables, use the export command.

export http_proxy=
export https_proxy=

Note that the export command sets temporarily environment variables that are only persistent on the shell you created the variable and the user who created the variable.

Hey, you want to learn how to configure Squid proxy and Squid Proxy authentication on CentOS 7/Fedora 29? Check the links below;

How to Install and Configure Squid Proxy on Fedora 29/Fedora 28/CentOS 7

Setup Squid Proxy Authentication on Ubuntu 18.04/Fedora 29/28/CentOS 7

To set the proxy environment variables to apply to all the system users or persistent across all shells, you can append these lines to /etc/environment.

echo -e "http_proxy=\nhttps_proxy=" | sudo tee -a /etc/environment

Note that these settings will only take effect on login again since the /etc/environment is read on system login. However, you can still use netplan command to apply the settings.

sudo netplan apply

To test this out, try to download anything from the terminal or run the system update. You will see that the connections is happening through the proxy server.

--2019-03-23 12:34:05--
Connecting to
sudo apt update
0% [Connecting to (] [Connecting to (]...

To configure proxy settings for APT only, you can simply create proxy configuration file under /etc/apt/apt.conf.d/.

echo -e 'Acquire::http::Proxy "";\nAcquire::https::Proxy "";' | sudo tee /etc/apt/apt.conf.d/02proxy
Acquire::http::Proxy "";
Acquire::https::Proxy "";

If your proxy server requires username/password authentication, then the environment variables would set as below;


For APT;

Acquire::http::Proxy "http://Username:Password@";
Acquire::https::Proxy "https://Username:Password@";

If you are looking at running at command for just that moment via proxy, you may prefix apt command with proxy settings as shown below;

sudo 'http_proxy=' apt update


sudo 'http_proxy=http://Username:[email protected]:3128' apt update

Set System Proxy on Ubuntu 18.04 Network Settings

You can also set system proxy on Ubuntu 18.04 desktop Network settings. However, this may not apply system wide. Proxy is disabled by default.

set system wide proxy in Ubuntu 18.04

Hence click the settings icon and select manual. Enter the Proxy server details, IP address and the port.

set system wide proxy in Ubuntu 18.04

Once done, close the settings icon.

That is all about how to set system wide proxy on Ubuntu 18.04. Enjoy.


    • Hello there.
      – Comment (by adding # to the beginning of the line) every proxy line added to /etc/environment file,
      – Unset the environment variables set e.g unset http_proxy


Please enter your comment!
Please enter your name here