chrome报错ERR_UNSAFE_PORT - Sat, Oct 9, 2021
chrome报错ERR_UNSAFE_PORT
chrome报错ERR_UNSAFE_PORT
问题背景
Chrome浏览器默认会阻止某些非标准端口的访问,这是为了防止安全风险。当尝试访问这些端口时会显示"ERR_UNSAFE_PORT"错误。
解决方法
方法1:允许特定端口(推荐)
启动Chrome时添加允许的端口参数:
# Linux
google-chrome-stable --explicitly-allowed-ports=80,10080
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --explicitly-allowed-ports=80,10080
# Windows
chrome.exe --explicitly-allowed-ports=80,10080
方法2:修改端口
将服务改为使用标准端口(80, 443, 8080等)。
方法3:使用其他浏览器
某些浏览器对端口限制较宽松,可以尝试使用Firefox等浏览器。
Chrome默认禁止的端口
Chrome默认禁止以下端口:
- 7 (echo)
- 9 (discard)
- 11 (systat)
- 13 (daytime)
- 15 (netstat)
- 17 (qotd)
- 19 (chargen)
- 20 (ftp data)
- 21 (ftp control)
- 22 (ssh)
- 23 (telnet)
- 25 (smtp)
- 37 (time)
- 42 (name)
- 43 (nicname)
- 53 (domain)
- 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)
- 139 (netbios)
- 143 (imap2)
- 179 (bgp)
- 389 (ldap)
- 465 (smtp+ssl)
- 512 (print/exec)
- 513 (login)
- 514 (shell)
- 515 (printer)
- 526 (tempo)
- 530 (courier)
- 531 (chat)
- 532 (netnews)
- 540 (uucp)
- 556 (remotefs)
- 563 (nntp+ssl)
- 587 (smtp+tls)
- 601 (syslog-conn)
- 636 (ldap+ssl)
- 993 (imap+ssl)
- 995 (pop3+ssl)
- 2049 (nfs)
- 3659 (apple-sasl)
- 4045 (lockd)
- 6000 (x11)
- 6665-6669 (irc)
- 6697 (irc+ssl)
安全建议
- 避免使用非标准端口:尽量使用标准的HTTP/HTTPS端口
- 生产环境:在生产环境中配置反向代理使用标准端口
- 开发环境:仅在开发环境允许特定端口