curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused
·
1、终端检查 curl http://www.baidu.com 是否可用
# 查看环境变量中的代理设置 echo $http_proxy echo $https_proxy echo $all_proxy
# 临时取消代理(只对当前会话有效) unset http_proxy unset https_proxy unset all_proxy # 然后重新测试 curl http://www.baidu.com
方法1:
# 检查bash配置文件 cat ~/.bashrc | grep proxy cat ~/.bash_profile | grep proxy cat /etc/profile | grep proxy # 检查系统配置文件 cat /etc/environment | grep -i proxy
# 编辑bash配置文件 vim ~/.bashrc # 找到类似下面的行并注释或删除: # export http_proxy="127.0.0.1:8080" # export https_proxy="127.0.0.1:8080" # 重新加载配置 source ~/.bashrc
方法2:
1. 首先编辑 /etc/environment 文件
# 注释掉类似这样的行: # http_proxy="http://127.0.0.1:8080" # https_proxy="http://127.0.0.1:8080" # ftp_proxy="http://127.0.0.1:8080" # 或者直接删除这些行
修改完 /etc/environment 后,重新SSH登录服务器,这样最稳妥。
方法3:
ls -la /etc/profile.d/ | grep -i proxy
例如出现
[root@yunk0gZ5 ~]# ls -la /etc/profile.d/ | grep -i proxy
-rwxr-xr-x 1 root root 383 Sep 20 18:58 netmon-unified-proxy.sh
这个 netmon-unified-proxy.sh 文件就是设置代理的源头!我们来处理它:
# 重命名文件(备份) sudo mv /etc/profile.d/netmon-unified-proxy.sh /etc/profile.d/netmon-unified-proxy.sh.bak # 或者直接删除 sudo rm /etc/profile.d/netmon-unified-proxy.sh
# 如果不想删除,可以清空文件内容 sudo echo "" > /etc/profile.d/netmon-unified-proxy.sh
操作后需要重新加载配置:
# 重新加载profile配置 source /etc/profile
重新SSH登录
# 检查代理环境变量 echo $http_proxy echo $https_proxy # 测试网络连接 curl http://www.baidu.com
更多推荐
所有评论(0)