正在使用wget下载包的时候,出现了拒绝连接的错误
[root@CentOS7 local]# wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
--2020-04-11 23:46:24-- http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
正在连接 127.0.0.1:8118... 失败:拒绝连接。
查找问题的方法如下:
- 查看本地端口是否被占用
[root@CentOS7 local]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1151/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1480/master
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1612/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1150/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1151/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1480/master
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 1150/sshd
- 本地端口8118并没有被占用
- 查看本地网络代理
[root@CentOS7 local]# export | grep -i proxy
declare -x ftp_proxy="http://127.0.0.1:8118"
declare -x http_proxy="http://127.0.0.1:8118"
declare -x https_proxy="http://127.0.0.1:8118"
- 网络http确实有代理,几乎可以断定是这个代理引发的错误。
解决办法:
- 尝试关闭代理,然后重新使用wget下载
[root@CentOS7 local]# unset http_proxy
[root@CentOS7 local]# wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
--2020-04-11 23:48:38-- http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
正在解析主机 jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)... 150.65.7.130, 2001:df0:2ed:feed::feed
正在连接 jaist.dl.sourceforge.net (jaist.dl.sourceforge.net)|150.65.7.130|:80... 已连接。
wget连接成功!