listen tcp :25: bind: address already in use
Closed this issue · 5 comments
maxbad commented
我现在是windows下使用goland, 程序再 wsl2中调试. 老是监听不起25端口
再 wsl2 里面执行 netstat -tunlop 返回下面
root@maxbad-801:~# netstat -tunlop
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Timer
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 181/systemd-resolve off (0.00/0/0)
tcp 0 0 127.0.0.1:49000 0.0.0.0:* LISTEN - off (0.00/0/0)
tcp 0 0 127.0.0.1:49443 0.0.0.0:* LISTEN - off (0.00/0/0)
tcp6 0 0 :::8070 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::8443 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::9443 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::12002 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::12003 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::12000 :::* LISTEN - off (0.00/0/0)
tcp6 0 0 :::12001 :::* LISTEN - off (0.00/0/0)
udp 0 0 127.0.0.53:53 0.0.0.0:* 181/systemd-resolve off (0.00/0/0)
udp 0 0 127.0.0.1:323 0.0.0.0:* - off (0.00/0/0)
udp6 0 0 ::1:323 :::* - off (0.00/0/0)
root@maxbad-801:~#
maxbad commented
郁闷了, 再 docker 容器中运行也是一样的,这应该是有点问题.
listen tcp :25: bind: address already in use
或者
listen tcp :465: bind: address already in use
Jinnrry commented
尝试用root权限启动呢,linux要求低位端口需要root权限。另外,直接在windows上面启动呢,wsl的网络过于复杂,我也不知道怎么排查
maxbad commented
看着应该是代码的问题哦, 同时启动2个携程, 2个携程里面共用了 变量 instance ,而 instanceTls 没用到
go smtp_server.Start()
go smtp_server.StartWithTLS()
Jinnrry commented
确实代码有问题,已经修复了
maxbad commented
看到了,谢谢大佬