Linux下服务端口被占用
有一次,在启动ejabberd的时候,报错如下:
10:30:15 =CRASH REPORT==== crasher: initial call: supervisor:ejabberd_listener/1 pid: <0.1224.0> registered_name: ejabberd_listeners exception exit: {{bad_return_value,{eaddrinuse,{5280,{0,0,0,0},tcp}}},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,356}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]} ancestors: [ejabberd_sup,<0.42.0>] messages: [] links: [#Port<0.6428>,<0.1198.0>] dictionary: [] trap_exit: true status: running heap_size: 1598 stack_size: 27 reductions: 2026 neighbours: 10:30:15 =SUPERVISOR REPORT==== Supervisor: {local,ejabberd_sup} Context: start_error Reason: {bad_return_value,{eaddrinuse,{5280,{0,0,0,0},tcp}}} Offender: [{pid,undefined},{id,ejabberd_listener},{mfargs,{ejabberd_listener,start_link,[]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}
报的是eaddrinuse 5280端口,也就是此端口被占用。
netstat -lnt|grep 5280 %查看端口5280端口的使用情况
看到有个 0.0.0.0 d listen 的监听进程.
然后,查看端口被哪个进程占用
lsof -i:5280
最后,杀掉该进程,重新再启动ejabberd服务.
kill -9 pid
ps: 这里之前启动了一个服务,占用了5280端口,导致im服务无法启动.