使用net/http/pprof时,发现6000端口是Chrome限制的非安全端口,报错ERR_UNSAFE_PORT

问题

最近在go项目中,涉及到性能分析,使用了go自有的net/http/pprof包,设置了6000端口后,发现浏览器打不开。PC上只有Edge和Chrome两个浏览器,刚好都是chrome内核。排查了系统问题、端口占用问题后,一直卡在这里-_-

使用net/http/pprof时,发现6000端口是Chrome限制的非安全端口,报错ERR_UNSAFE_PORT_第1张图片

原因 

后面发现浏览器报错了ERR_UNSAFE_PORT。才知道浏览器为了安全问题,会禁用一些网络浏览以外的端口——非安全端口。还是对问题的查找不够仔细,一直想着代码或者是系统问题,没有想到浏览器问题。

下面列出Chrome浏览器默认的非安全端口,避雷!!!

Chrome浏览器默认非安全端口
端口 端口作用
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
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 stmp(rfc-6409)
601 syslog-con(rfc-3195)
636 ldap+ssl
993 ldap+ssl
995 pop3+ssl
2049 nfs
3659 apple-sasl / PasswordServer
4045 lockd
6000 X11
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

解决方案

最好的解决方案就是避开这些端口。

你可能感兴趣的:(go,chrome,http,前端)