• 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.

  • 相关阅读:
    BZOJ2286 [Sdoi2011]消耗战 【虚树 + 树形Dp】
    BZOJ1305 [CQOI2009]dance跳舞 【网络流】
    BZOJ1452 [JSOI2009]Count 【树套树 (树状数组)】
    BZOJ1103 [POI2007]大都市meg 【树剖】
    BZOJ1927 [Sdoi2010]星际竞速 【费用流】
    POJ3450 Corporate Identity 【后缀数组】
    POJ3623 Best Cow Line, Gold 【后缀数组】
    POJ3415 Common Substrings 【后缀数组 + 单调栈】
    关于线上bug
    关于线上bug
  • 原文地址:https://www.cnblogs.com/seeken/p/10773978.html
Copyright © 2020-2023  润新知