Not able to update/install any package using apt-get in Debian/Ubuntu. Accessing network in terminal when internet is configured with a proxy is troublesome sometimes.
As you can see in the above image, it just keeps on connecting until the server is timed out.
Below is the easiest way to setup a proxy for your network to access internet in terminal with no hassle.
User need to set the proxy for apt-get. To set the proxy for apt-get, edit the file
We use this acquire command to setup proxy for both http and https int the below format.
Acquire::http::Proxy "http://proxy:port"; Acquire::https::Proxy "https://proxy:port"; Acquire::ftp::Proxy "ftp://proxy:port";
Note: Sometimes your OS requries authentication before setting up proxy for the network. For that use the below format,
Acquire::http::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]"; Acquire::https::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
passwordare your laptops/PC's login username and password.
- To define proxy settings for apt, create or edit (if it already exists) a file named apt.conf in /etc/apt directory:
sudo nano /etc/apt/apt.conf
- Add the following lines to the file: For eg,
Acquire::http::Proxy "http://127.0.0.1:8080"; Acquire::https::Proxy "http://127.0.0.1:8080";
Note: Here, replace these proxy and port values from your network proxy.
Save the file by pressing Ctrl + X and then hit Enter!
Now Source the file to update the changes in terminal.
- That's it! Now try to run the below command.
sudo apt-get update
Hope it helps you guys!. Thanks for supporting.
I have posted a video explanation on Youtube. Do check it out!