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.

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. animate-queue和step-animate

    Step-animate: 分为3部分:{配置},{step:function(){...},duration:1000} <div id="warpper" style=& ...

  2. vue学习之vuex

    1  首先还是安装 npm install vuex --save. 2 在src这种创建目录为store 创建 index.js  (getters.js ,actions.js ,mutation ...

  3. 《JavaScript高级程序设计》笔记:DOM(十)

    Node类型 nodeType以下是一些重要的nodeType的取值:1: 元素element2: 属性attr3: 文本text8: 注释comments9: 文档document nodeName ...

  4. 微信小程序中通过腾讯地图进行逆地址解析报错message: "请求来源未被授权, 此次请求来源域名:servicewechat.com"

    在小程序中获取定位具体信息时,不要配置腾讯地图中的WebServiceAPI中的域名白名单什么的,域名配置直接在小程序后台中配置(就是这个货https://apis.map.qq.com), 千万千万 ...

  5. First Show

    随便写写,记录美好生活 博客的内容主要是关于java后台开发所涉及到技术栈的学习记录

  6. SQL 获取时间段内日期列表

    declare @start date,@end date; set @start='2010-01-01'; set @end='2010-02-01'; --获取时间段内日期列表 select [ ...

  7. git排除插件(.ignore)配置

    # Created by .ignore support plugin (hsz.mobi) ### Maven template target/ ### JetBrains template # C ...

  8. 【转】Dockerfile详解

    Dockerfile详解 https://blog.csdn.net/wo18237095579/article/details/80540571 --------------------- 作者:大 ...

  9. CDH集成Kafka,两种方式:离线、在线

    1.离线 先下载相应版本的kafka http://archive.cloudera.com/kafka/parcels/ 然后放置相应目录,如下图: 然后直接添加组件即可 2.在线 配置相应的kaf ...

  10. egg.js与mysql的结合使用,以及部署事项

    最近使用egg.js写了一个小项目练手,主要用来封装接口以及代理接口.进入正题: egg搭建以及各项配置 可以详见官方文档:https://eggjs.org,这里简单描述一下: 1.直接使用脚手架快 ...