解决Chrome端口限制导致ERR_UNSAFE_PORT的问题
今天在安装wordpress的时候,使用ip+端口访问的方式没有问题,但是当换成域名+https的时候却遇到了问题。由于博主把wordpress的端口设置为
10080
,使用域名打开的时候浏览器却无法打开,报ERR_UNSAFE_PORT错误。经过一番查找,总算找到了原因。
原因
网址为 xxx 的网页可能暂时无法连接,或者它已永久性地移动到了新网址。
ERR_UNSAFE_PORT
出现ERR_UNSAFE_PORT的原因,是因为浏览器为了安全考虑,会阻止一些端口访问,一般包含如下端口:
1, // tcpmux
7, // echo
9, // discard
11, // systat
13, // daytime
15, // netstat
17, // qotd
19, // chargen
20, // ftp data
21, // ftp access
22, // ssh
23, // telnet
25, // smtp
37, // time
42, // name
43, // nicname
53, // domain
69, // tftp
77, // priv-rjs
79, // finger
87, // ttylink
95, // supdup
101, // hostriame
102, // iso-tsap
103, // gppitnp
104, // acr-nema
109, // pop2
110, // pop3
111, // sunrpc
113, // auth
115, // sftp
117, // uucp-path
119, // nntp
123, // NTP
135, // loc-srv /epmap
137, // netbios
139, // netbios
143, // imap2
161, // snmp
179, // BGP
389, // ldap
427, // SLP (Also used by Apple Filing Protocol)
465, // smtp+ssl
512, // print / exec
513, // login
514, // shell
515, // printer
526, // tempo
530, // courier
531, // chat
532, // netnews
540, // uucp
548, // AFP (Apple Filing Protocol)
554, // rtsp
556, // remotefs
563, // nntp+ssl
587, // smtp (rfc6409)
601, // syslog-conn (rfc3195)
636, // ldap+ssl
993, // ldap+ssl
995, // pop3+ssl
1719, // h323gatestat
1720, // h323hostcall
1723, // pptp
2049, // nfs
3659, // apple-sasl / PasswordServer
4045, // lockd
5060, // sip
5061, // sips
6000, // X11
6566, // sane-port
6665, // Alternate IRC [Apple addition]
6666, // Alternate IRC [Apple addition]
6667, // Standard IRC [Apple addition]
6668, // Alternate IRC [Apple addition]
6669, // Alternate IRC [Apple addition]
6697, // IRC + TLS
10080, // Amanda
所以,当访问的网站使用以上端口时会被浏览器阻止。
解决方法
解决方案有2种,一种是修改网站的端口,另一种是修改浏览器的限制。
方法一
建议:
这个方法就很简单了,直接改网站监听的端口就行了,不要使用受限制的端口即可。
方法二
- Windows
选择浏览器快捷放肆,
右键
——属性
,然后在模版目标
中填入一下内容即可:--explicitly-allowed-ports=10080
支持多个端口,使用逗号分隔。
- MacOs系统
Mac系统相对麻烦点,进入浏览器的目录,以Chrome为例:
cd "/Applications/Google Chrome.app/Contents/MacOS/" # 备份 sudo mv "Google Chrome" Google.bk # 重新创建浏览器启动项 sudo printf '#!/bin/bash\ncd "/Applications/Google Chrome.app/Contents/MacOS"\n"/Applications/Google Chrome.app/Contents/MacOS/Google.real" --explicitly-allowed-ports=10080,6000 "$@"\n' > Google\ Chrome # 添加执行权限 sudo chmod u+x "Google Chrome"