zoukankan      html  css  js  c++  java
  • ubuntu apt update failed to fetch

    When I do command sudo apt update, always get belowing errors:

    Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
      Could not connect to archive.ubuntu.com:80 (91.189.91.23). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.149). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.152). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.161). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.162). - connect (111: Connection refused)
    Err:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
      Unable to connect to archive.ubuntu.com:http:
    Err:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
      Unable to connect to archive.ubuntu.com:http:
    Err:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
      Could not connect to security.ubuntu.com:80 (91.189.88.162). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.91.23). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.91.26). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.149). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.152). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.161). - connect (111: Connection refused)
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    All packages are up to date.
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not connect to archive.ubuntu.com:80 (91.189.91.23). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.149). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.152). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.161). - connect (111: Connection refused) Could not connect to archive.ubuntu.com:80 (91.189.88.162). - connect (111: Connection refused)
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Unable to connect to archive.ubuntu.com:http:
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Unable to connect to archive.ubuntu.com:http:
    W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not connect to security.ubuntu.com:80 (91.189.88.162). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.91.23). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.91.26). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.149). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.152). - connect (111: Connection refused) Could not connect to security.ubuntu.com:80 (91.189.88.161). - connect (111: Connection refused)
    W: Some index files failed to download. They have been ignored, or old ones used instead.

    and I have done my proxy setting in file .bash_profile like:

    function setproxy
    {
          export {http,ftp}_proxy=xx.yy.com:80  
    }
    
    function unsetproxy
    {
        unset {http,ftp}_proxy
    }
    
    setproxy

    and check it with command env | grep -i proxy:

    kay@cn:~$ env | grep -i proxy
    http_proxy=xx.yy.com:80
    ftp_proxy=xx.yy.com:80

    At last, I found what I should do is to create an apt proxy conf file.

    Apt loads all configuration files under /etc/apt/apt.conf.d. We can create a configuration specifically for our proxy there, keeping it separate from all other configurations.

    Create a new configuration file named proxy.conf.
    sudo touch /etc/apt/apt.conf.d/proxy.conf
    Open the proxy.conf file in a text editor.
    sudo vi /etc/apt/apt.conf.d/proxy.conf
    Add the following line to set your HTTP proxy.
    Acquire::http::Proxy "http://user:password@proxy.server:port/";
    Add the following line to set your HTTPS proxy.
    Acquire::https::Proxy "http://user:password@proxy.server:port/";
    Save your changes and exit the text editor.

    Your proxy settings will be applied the next time your run Apt.

  • 相关阅读:
    连续多步骤业务流程的暂停、中断和恢复
    什么是XML
    泛型擦除和反射配置文件
    类加载器和反射
    网络安全协议(二)
    网络通信协议(一)
    多线程之线程安全
    JAVA之线程池
    JAVA之多线程
    2020/8/1 JAVA之IO流(四)
  • 原文地址:https://www.cnblogs.com/seeken/p/10773978.html
Copyright © 2011-2022 走看看