I set the proxy using system setting -> Network -> Network Proxy. I then clicked on "Apply system wide", put my password, and nothing else.

michele@rserver-VirtualBox:~$ wget http://bbc.co.uk
--2014-09-30 13:02:20--  http://bbc.co.uk/
Resolving datapx01-wcg (datapx01-wcg)...
Connecting to datapx01-wcg (datapx01-wcg)||:8080... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: http://www.bbc.co.uk/ [following]
--2014-09-30 13:02:21--  http://www.bbc.co.uk/
Reusing existing connection to datapx01-wcg:8080.
Proxy request sent, awaiting response... 200 OK
Length: 103020 (101K) [text/html]
Saving to: ‘index.html’

100%[======================================>] 103,020      190KB/s   in 0.5s   

2014-09-30 13:02:21 (190 KB/s) - ‘index.html’ saved [103020/103020]

Instead using sudo:

michele@rserver-VirtualBox:~$ sudo wget http://bbc.co.uk
[sudo] password for michele: 
--2014-09-30 13:02:30--  http://bbc.co.uk/
Resolving bbc.co.uk (bbc.co.uk)...,,, ...
Connecting to bbc.co.uk (bbc.co.uk)||:80... failed: Connection timed out.

I am on 14.04 and I didn't have this issue before upgrading from 12.04 yesterday. Please tell me what other info you need.

  • Why do you want to use sudo here while it works well without that? Commented Sep 30, 2014 at 12:11
  • Check your /etc/apt/apt.conf file and see if your proxy setting is also appear there. Commented Sep 30, 2014 at 12:18
  • that is simply a reproducible example... my server runs application on behalf of different users, so I need the proxy to work for all users.
    – Michele
    Commented Sep 30, 2014 at 12:19
  • 1
    To workaround, use it like this: sudo env HTTP_PROXY=http://proxy.example.com:port wget http://bbc.co.uk.
    – s3lph
    Commented Sep 30, 2014 at 12:22
  • Did you try @the_Seppi's suggestion? When you run sudo, environment is restricted.
    – Lety
    Commented Sep 30, 2014 at 18:29

2 Answers 2


In case anybody wonders:

The issue here, is that when sudoing, a newenvironment is loaded, meaning that http_proxy is no longer set.

To resolve this issue you can add Defaults env_keep += "http_proxy https_proxy" to your /etc/sudoers file in order to keep those variables when switching to the secure path.

Reference: https://help.ubuntu.com/community/EnvironmentVariables

  • super answer!! worked in CentOS 7 as well.
    – Ubuntuser
    Commented Apr 9, 2018 at 8:52
  • Just a note: this would still requires the respective environment variables to be set inside the profile of the user, who belongs to the sudoers. Add export http_proxy=... and export https_proxy=... to .bashrc or whatever your user's profile file is called. Also I recommend putting no_proxy, which is quite common for company networks, where internal network locations (e.g. intranet web portal) often not only do not require but will not work if going through proxy. Commented Apr 1, 2022 at 6:21

Open /etc/apt/apt.conf file in Terminal and set your proxy setting as following:

Acquire::http::proxy "http://user:pass@host:port/";
Acquire::https::proxy "https://user:pass@host:port/";
Acquire::ftp::proxy "ftp://user:pass@host:port/";
Acquire::socks::proxy "socks://user:pass@host:port/";

Replace user with your username, pass with your password, host with proxy-webaddress and port with a portnumber.

  • Those 4 lines are already there. But without the username and password. I ll try adding them
    – Michele
    Commented Sep 30, 2014 at 12:39
  • Just did, still the same
    – Michele
    Commented Sep 30, 2014 at 13:45
  • @Michele run echo $http_proxy in terminal did you see the your user and pass and other configure? Commented Sep 30, 2014 at 14:02
  • I just get the http://proxy:port/
    – Michele
    Commented Sep 30, 2014 at 14:04
  • @Michele then your user and pass not set correctly!! Commented Sep 30, 2014 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .