When I attempt to install packages through sudo apt-get install, no matter what I try to install, it returns a 111: Connection Refused error.

The web browser appears to work, but not sudo apt-get install. I attempted to install Ruby, PHP, and open-shift RHC tools, and I also attempted to use Synaptic to update/install packages, and I was unable to.

I get errors similar to the following, every time:

W: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main          /liby/libyaml  > /libyaml-0-2_0.1.4-3ubuntu3.1_i386.deb
Could not connect to ( - connect (111: Connection refused)

I am using Ubuntu 14.04.1 LTS.

I connect to my adsl router via wireless, and am running an image that i got from my university running on vmware, using Windows 10. The university used a proxy but I edited it out in the M2 setting file and edited firefox to auto detect proxy to get my internet working

Please can someone help me figure out how to fix this?


See if there's a proxy set in /etc/apt/apt.conf (or somewhere in /etc/apt/apt/apt.conf.d).

There'll be a file with a line something like: Acquire::http::Proxy "";

Comment the line(s) by putting a # at the beginning of it and try again.

| improve this answer | |
  • I dont have either of those files, I only have one apt folder – Lance Sep 25 '15 at 15:03
  • think it was using a maven proxy before – Lance Sep 25 '15 at 15:04
  • I doubt apt-get was using a maven proxy - or at least I've never heard of such a thing... – ssta Sep 25 '15 at 15:42
  • I had to remove proxy setting in mavens settings.xml and change firefox to auto-detect proxy settings in order to access the internet but still get the same error when trying to download a package – Lance Sep 26 '15 at 7:48

I solve this error by removing network settings.

I do :

cat /etc/apt/apt.conf 

If I see this

Acquire::http::proxy "http://macth-with-your-ip-or-dns-setting:8080/";
Acquire::https::proxy "https://macth-with-your-ip-or-dns-setting:9999/";

I go to network system settings and choose network then select Network Proxy Method see drop-down menu, choose manual then DELETE all settings there. Click Apply to save the setting or configuration that you made.

In the terminal do

cat /etc/apt/apt.conf

if there is no output, you have finished and you can apt-get update

| improve this answer | |

Could not connect to x.x.x.x:8080

Connection to IP:8080 indicates that you're using proxy.

Here are few suggestions:

  • Check by: apt-config dump | grep -i proxy.
  • If proxy is used, edit /etc/apt/apt.conf file or check for config files in /etc/apt/apt.conf.d/ or find by grep -ri proxy /etc/apt/, then adjust or remove the proxy.
  • To check the direct connection to security.ubuntu.com, run:

    curl http://security.ubuntu.com/ && echo Works

    To test the connection through proxy, run:

    curl -x http://PROXYIP:8080/ http://security.ubuntu.com/ && echo Works
  • To debug networking for apt-get command, you can run:

    strace -f -e network apt-get update 2>&1 | grep -C10 refused
  • Check your firewall rules and network configuration.

| improve this answer | |
  1. First check /etc/apt/apt.conf: if you found Acquire::http::proxy "http://x.x.x.x:8080/" just commented it with (#) at the beginning of the line.

  2. Then check /etc/environment: if you found http_proxy="http://x.x.x.x:8080/" just commented it with (#) on the beginning of the line.

| improve this answer | |

If you are using the WSL(Windows Subsystem for Linux) version of Ubuntu, make sure you don't have any 3rd party Antivirus/firewalls enabled.

Try deactivating them and see if the connection goes back to normal.

There are known issues regarding 3rd party firewalls that do not behave well with WSL.

See the WSL GitHub issues 475 and 1720 for more details.

| improve this answer | |

Old post, I know, but had this same issue on 18.04 and none of the posts I found had the solution that eventually worked for us. Adding it to the collective...

Err:4 http://security.ubuntu.com/ubuntu xenial-security InRelease Could not connect to security.ubuntu.com:80 ( - connect (111: Connection refused)

No proxy/Not using a proxy. Ping out okay. resolv.conf only has internal nameserver entries.

Issue was resolved by removing a manual entry: security.ubuntu.com in /etc/hosts

Good luck!

| improve this answer | |
  1. In command prompt, enter sudo nano /etc/apt/apt.conf
  2. Delete (or comment out) the contents of the file, press Ctrl+O and then Ctrl+X
  3. Enter sudo apt update
  4. Resume doing what you were previously doing.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.