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

  1. Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
  2. 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)
  3. Err:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  4. Unable to connect to archive.ubuntu.com:http:
  5. Err:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  6. Unable to connect to archive.ubuntu.com:http:
  7. Err:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
  8. 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)
  9. Reading package lists... Done
  10. Building dependency tree
  11. Reading state information... Done
  12. All packages are up to date.
  13. 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)
  14. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to archive.ubuntu.com:http:
  15. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to archive.ubuntu.com:http:
  16. 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)
  17. 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:

  1. function setproxy
  2. {
  3. export {http,ftp}_proxy=xx.yy.com:80
  4. }
  5.  
  6. function unsetproxy
  7. {
  8. unset {http,ftp}_proxy
  9. }
  10.  
  11. setproxy

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

  1. kay@cn:~$ env | grep -i proxy
  2. http_proxy=xx.yy.com:80
  3. 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.

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

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

ubuntu apt update failed to fetch的更多相关文章

  1. Ubuntu apt update卡在Connecting to security.ubuntu.com解决方法

    Ubuntu操作系统运行apt update命令时会卡在Connecting to security.ubuntu.com,搭了梯子也无法解决 尝试了网络上的方法,如: https://blog.cs ...

  2. ubuntu apt update时W: GPG error http://ppa.launchpad.net lucid Release没有公钥无法验证NO_PUBKEY签名问题解决

    在安装更新时,即在运行命令行sudo apt-get update 或者运行更新管理器的时候,出现W: GPG 错误: W: GPG error: http://ppa.launchpad.net/o ...

  3. ubuntu 执行apt-get update报错Failed to fetch

    在ubuntu下执行sudo apt-get update时,经常会遇到报错: Err http://security.ubuntu.com precise-security InRelease Er ...

  4. 【转】ubuntu apt-get update 失败解决

    FROM : http://blog.csdn.net/ronghua_liu/article/details/8609450 当运行apt-get update后出现如下错误时:E: Some in ...

  5. [置顶] ubuntu版本很老,apt-get update更新失败时(W: Failed to fetch ...)------如何创建新的sources.list

    在说这个解决方案之前,我先说下,目前遇到的问题: 我使用 sudo apt-get update 之后,更新失败.具体原因如下: W: Failed to fetch http://cn.archiv ...

  6. Ubuntu sudo apt-get update提示 Failed to fetch,解决办法

    问题: 执行sudo apt-get update提示:Failed to fetch chen@ubuntu:~/soft/Python-$ sudo apt-get update Get: htt ...

  7. apt-get update --> Bad header line (fresh install) Ign http://archive.ubuntu.com natty-security/multiverse Sources/DiffIndex W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/natty/Rele

    apt-get update --> Bad header line (fresh install) fresh natty install i386 desktop. I get this e ...

  8. [置顶] apt-get update 更新失败----如何清除破损而且陈旧的PPA仓库 (W: Failed to fetch http://ppa.launchpad.net/jonathonf/pyt)

    我使用sudo apt-get update之后,更新失败,遇到如下错误. W: Failed to fetch http://ppa.launchpad.net/jonathonf/python-3 ...

  9. ubuntu 更新源 或者 apt-get install 出错404 not found ,Failed to fetch

    1.考虑是不是能上网 2.用apt-get update ,然后再试试apt-get install 如果apt-get update 也出现很多 404 not found 或者 failed to ...

随机推荐

  1. Spring Boot Security 整合 JWT 实现 无状态的分布式API接口

    简介 JSON Web Token(缩写 JWT)是目前最流行的跨域认证解决方案.JSON Web Token 入门教程 - 阮一峰,这篇文章可以帮你了解JWT的概念.本文重点讲解Spring Boo ...

  2. 享元模式 FlyWeight 结构型 设计模式(十五)

    享元模式(FlyWeight)  “享”取“共享”之意,“元”取“单元”之意. 意图 运用共享技术,有效的支持大量细粒度的对象. 意图解析 面向对象的程序设计中,一切皆是对象,这也就意味着系统的运行将 ...

  3. html&css学习一

    HTML标签 HTML骨架 <HTML> <head> <title></title> </head> <body> </ ...

  4. jsp内置对象-application对象

    隐含对象application是javax.servlet.ServletContext接口实现类的对象,其拥有application的作用范围,即application可以用于在多个用户之间保存数据 ...

  5. 虹软免费人脸识别SDK注册指南

    成为开发者三步完成账号的基本注册与认证:STEP1:点击注册虹软AI开放平台右上角注册选项,完成注册流程.STEP2:首次使用,登录后进入开发者中心,点击账号管理完成企业或者个人认证,若未进行实名认证 ...

  6. 简单的C#实体映射 AutoMapper

    AutoMapper是对象到对象的映射工具.在完成映射规则之后,AutoMapper可以将源对象转换为目标对象. 要映射实体 public class SourceModel { public int ...

  7. anaconda的scikit-learn报错It seems that scikit-learn has not been built

    我们在导入sklearn时往往会报错. import sklearn Traceback (most recent call last): File "<stdin>" ...

  8. 光盘安装win7系统教程

    光盘安装系统是最传统的安装系统的方法,虽然现在U盘安装和硬盘安装已经很方便,但仍有很多用户习惯光盘安装的方式,下面小编教大家如何利用光盘安装系统. 来源:https://www.haoxitongx. ...

  9. UOJ #269. 【清华集训2016】如何优雅地求和

    UOJ #269. [清华集训2016]如何优雅地求和 题目链接 给定一个\(m\)次多项式\(f(x)\)的\(m+1\)个点值:\(f(0)\)到\(f(m)\). 然后求: \[ Q(f,n,x ...

  10. 好程序员告诉你HTML好在哪里,为什么值得我们学习

    好程序员告诉你HTML好在哪里,为什么值得我们学习,HTML5对于用户来说,提高了用户体验,加强了视觉感受.HTML5技术在移动端,能够让应用程序回归到网页,并对网页的功能进行扩展,用户不需要下载客户 ...