sudo apt-get update : Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)

8,916

The error

Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)

suggests that your system is configured to use a local HTTP proxy for apt connections (and that no such proxy is running).

You can temporarily override this setting on the command line by passing an empty value Acquire::Http::Proxy= on the command line e.g.

sudo apt-get -oAcquire::Http::Proxy= update

If that works and you believe that the proxy configuration is inappropriate, then you can make the setting persistent by locating and either commenting out or removing any lines related to proxy configurations in your apt configuration files - /etc/apt/apt.conf and associated files in the /etc/apt/apt.conf.d/ directory - as well as an entry for HTTP you may find entries for HTTPS and/or socks protocols.

Share:
8,916

Related videos on Youtube

sujeet
Author by

sujeet

Electronics and Communication Engineer

Updated on September 18, 2022

Comments

  • sujeet
    sujeet almost 2 years
    turtlebot@turtlebot-bot:~$ sudo apt-get update
    
    Err:1 http://ports.ubuntu.com xenial InRelease Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    Err:2 http://ports.ubuntu.com xenial-updates InRelease Unable to connect to localhost:9999:
    
    Err:3 http://ports.ubuntu.com xenial-security InRelease Unable to connect to localhost:9999:
    
    Err:4 http://ports.ubuntu.com xenial-backports InRelease Unable to connect to localhost:9999:
    
    Err:5 http://ppa.launchpad.net/flexiondotorg/minecraft/ubuntu xenial InRelease Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    Err:6 http://ppa.launchpad.net/ubuntu-mate-dev/welcome/ubuntu xenial InRelease Unable to connect to localhost:9999:
    
    Err:7 http://packages.ros.org/ros/ubuntu xenial InRelease
    Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    Err:8 http://ppa.launchpad.net/ubuntu-mate-dev/xenial-mate/ubuntu xenial InRelease Unable to connect to localhost:9999:
    
    Err:9 http://ppa.launchpad.net/ubuntu-pi-flavour-makers/ppa/ubuntu xenial InRelease Unable to connect to localhost:9999:
    
    Err:10 http://ppa.launchpad.net/wireshark-dev/stable/ubuntu xenial InRelease
    
    Unable to connect to localhost:9999: Reading package lists... Done
    
    W: Failed to fetch http://ports.ubuntu.com/dists/xenial/InRelease Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    W: Failed to fetch http://ports.ubuntu.com/dists/xenial-updates/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ports.ubuntu.com/dists/xenial-security/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ports.ubuntu.com/dists/xenial-backports/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ppa.launchpad.net/flexiondotorg/minecraft/ubuntu/dists/xenial/InRelease Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    W: Failed to fetch http://packages.ros.org/ros/ubuntu/dists/xenial/InRelease Could not connect to localhost:9999 (127.0.0.1). - connect (111: Connection refused)
    
    W: Failed to fetch http://ppa.launchpad.net/ubuntu-mate-dev/welcome/ubuntu/dists/xenial/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ppa.launchpad.net/ubuntu-mate-dev/xenial-mate/ubuntu/dists/xenial/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ppa.launchpad.net/ubuntu-pi-flavour-makers/ppa/ubuntu/dists/xenial/InRelease Unable to connect to localhost:9999:
    
    W: Failed to fetch http://ppa.launchpad.net/wireshark-dev/stable/ubuntu/dists/xenial/InRelease Unable to connect to localhost:9999:
    
    W: Some index files failed to download. They have been ignored, or old ones used instead.
    
    turtlebot@turtlebot-bot:~$ lsb_release -a
    
    No LSB modules are available.
    
    Distributor ID: Ubuntu
    
    Description: Ubuntu 16.04.3 LTS
    
    Release: 16.04
    
    Codename: xenial
    

    PS: I didn't know the stack exchange culture. I was down voted by 5 when I published this same question in electronics.stackexchange.com as it was a question from turtlebot3-burgerbot. Anyways, I'm a novice in Linux realm and desperate to look for an answer. Thank you.

    • Bernard Wei
      Bernard Wei almost 6 years
      Please post the output of "dig ports.ubuntu.com" and "dig ppa.launchpad.net"
    • sujeet
      sujeet almost 6 years
      @Bernard; <<>> DiG 9.10.3-P4-Ubuntu <<>> ports.ubuntu.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33761 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;ports.ubuntu.com. IN A ;; ANSWER SECTION: ports.ubuntu.com. 700 IN A 91.189.88.150 ;; Query time: 1 msec ;; SERVER: 127.0.1.1#53(127.0.1.1) ;; WHEN: Mon Jul 23 15:59:10 CDT 2018 ;; MSG SIZE rcvd: 50
    • steeldriver
      steeldriver almost 6 years
      It looks like you configured your system to use a proxy (localhost:9999) at some point?
    • sujeet
      sujeet almost 6 years
      @Bernard dig ppa.launchpad.net ; <<>> DiG 9.10.3-P4-Ubuntu <<>> ppa.launchpad.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4745 ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;ppa.launchpad.net. IN A ;; ANSWER SECTION: ppa.launchpad.net. 654 IN A 91.189.95.83 ;; Query time: 1 msec ;; SERVER: 127.0.1.1#53(127.0.1.1) ;; WHEN: Mon Jul 23 16:39:51 CDT 2018 ;; MSG SIZE rcvd: 51
    • Bernard Wei
      Bernard Wei almost 6 years
      @SujeetPoudel would be easier to read if you update your original questions but nevertheless, I can see that it is okay in resolving the IP's so that localhost:9999 is more likly a proxy issue as indicated by steeldriver
    • sujeet
      sujeet almost 6 years
      @steeldriver : How can I reconfigure again to restore?
    • steeldriver
      steeldriver almost 6 years
      @sujeet please try sudo apt-get -oAcquire::Http::Proxy= update and report back what happens (note the space between = and update)
    • sujeet
      sujeet almost 6 years
      @steeldriver it is downloading something
    • sujeet
      sujeet almost 6 years
      @steeldriver yes that command worked... and, i also installed firefox using: sudo apt-get -oAcquire::Http::Proxy= install firefox ... is there a way to fix the issue? thanks
    • sujeet
      sujeet almost 6 years
      @steeldriver firefox did install but it throws errors and doesn't open
    • steeldriver
      steeldriver almost 6 years
      @sujeet for a permanent fix you will need to find where the proxy setting is configured (/etc/apt/apt.conf or one of the files in /etc/apt/apt.conf.d) and remove or comment out the line like Acquire::Http::Proxy. Your firefox issue sounds like something unrelated - it's hard to tell without know what errors exactly
    • sujeet
      sujeet almost 6 years
      @steeldriver apt.conf showed these four lines: Acquire::http::proxy "localhost:9999"; Acquire::https::proxy "localhost:9999"; Acquire::ftp::proxy "localhost:9999"; Acquire::socks::proxy "socks:localhost:9999";
    • sujeet
      sujeet almost 6 years
      @steeldriver there's nothing there in apt.conf.d
    • sujeet
      sujeet almost 6 years
      @steeldriver I commented those four lines and it works fine now. Thanks a lot. You can publish your answer and I will approve. Also please suggest me a good tutorial source for learning linux from scratch. I appreciate you.
  • MikaelF
    MikaelF almost 5 years
    The empty-proxy trick didn't work for me, but I was able to solve the proxy problem by going into All settings/Network/Network Proxy and clicking "Apply system wide".