Ubuntu – How to fix update errors for a server behind of a proxy

If you’re behind of a proxy server and the IP address has changed (or proxy it’s a new node in your network topology) then probably when you’re trying to update your binaries then you’ll get a list of errors.

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/multiverse/i18n/Translation-en_US Unable to connect to 192.168.120.240:3128:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/multiverse/i18n/Translation-en Unable to connect to 192.168.120.240:3128: 
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/restricted/i18n/Translation-en_US Unable to connect to 192.168.120.240:3128: 
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/restricted/i18n/Translation-en Unable to connect to 192.168.120.240:3128:

This happens because you’re unable to connect to Ubuntu mirrors. In order to fix this issue, you have to edit apt.conf file settings.
– Check the proxy settings in apt.conf file:

my-user@my-server:/#sudo -s
root@my-server:/# view /etc/apt/apt.conf

– Update the new proxy IP and port (ex. http://192.168.230.99:3128):

root@my-server:/# vi /etc/apt/apt.conf
Acquire::http::Proxy "http://192.168.230.99:3128";

If you need user and password for logging to the Proxy server this can be achieved in most cases by using the following layout:

Acquire::http::Proxy "http://username:password@your_proxy_address:proxy_port";

– Finally, you may enjoy running the update commands:

root@my-server:/# apt-get update
root@my-server:/# apt-get upgrade