栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

liunx使用网络代理

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

liunx使用网络代理

在linux使用sudo apt update 出现的bug:

提示:Ubuntu/debian若是通过unset http_proxy无法取消的网络代理
Could not connect to 127.0.0.1:8080 (127.0.0.1). - connect (111: Connection refused)
例如:在使用unset取消代理之后重启,依旧无法使用apt


问题描述

例如:

1.临时设置代理:

export http_proxy=“http://proxy-XXXXX”
export https_proxy=“https://proxy-XXXXX:”

2.临时取消代理:

unset http_proxy
unset https_proxy

3.查看代理:
env | grep xxx

4.再输入以下命令去掉相关代理。

sudo vi /etc/enviroment

5.再输入命令source bashrc和/etc/profile文件。

source .bashrc

source /etc/profile

6.重启之后,再次查看相关代理是否去掉


orangepi@orangepi4-lts:~$ sudo apt-get update
Err:1 http://mirrors.tuna.tsinghua.edu.cn/debian bullseye InRelease
  Could not connect to 127.0.0.1:8080 (127.0.0.1). - connect (111: Connection refused)
Err:2 http://mirrors.tuna.tsinghua.edu.cn/debian bullseye-updates InRelease
  Unable to connect to 127.0.0.1:8080:
Err:3 http://mirrors.tuna.tsinghua.edu.cn/debian bullseye-backports InRelease
  Unable to connect to 127.0.0.1:8080:
Err:4 http://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security InRelease
  Unable to connect to 127.0.0.1:8080:
Reading package lists... Done
W: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/debian/dists/bullseye/InRelease  Could not connect to 127.0.0.1:8080 (127.0.0.1). - connect (111: Connection refused)
W: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/debian/dists/bullseye-updates/InRelease  Unable to connect to 127.0.0.1:8080:
W: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/debian/dists/bullseye-backports/InRelease  Unable to connect to 127.0.0.1:8080:
W: Failed to fetch http://mirrors.tuna.tsinghua.edu.cn/debian-security/dists/bullseye-security/InRelease  Unable to connect to 127.0.0.1:8080:
W: Some index files failed to download. They have been ignored, or old ones used instead.
原因分析:

提示:建议您的系统配置为使用本地 HTTP 代理 apt连接(并且没有这样的代理正在运行)。
您可以通过传递一个空值在命令行上临时覆盖此设置 Acquire::Http::Proxy=在命令行上,例如

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

解决方案:

提示:如果这样可行 并且您认为代理配置不合适
那么您可以通过在您的 apt 配置文件中定位并注释掉或删除与代理配置相关的任何行来使设置持久化 - /etc/apt/apt.conf以及相关的文件 /etc/apt/apt.conf.d/目录 - 以及 HTTP 条目,您可以找到 HTTPS 和/或 socks 协议的条目。 :

root@orangepi4-lts:/etc/apt/apt.conf.d# ls
01autoremove	      02-orangepi-compress-indexes  20auto-upgrades  50appstream	    60icons    71-orangepi-no-recommends  81-orangepi-no-languages
01autoremove-kernels  02-orangepi-periodic	    20packagekit     50unattended-upgrades  70debconf  80proxy

注释掉80proxy里面的内容即可成功使用apt
如果你在项目中遇到相关的问题,可以在下面留言

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/866118.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号