로메오의 블로그

[netstat] 포트확인해서 프로세스 종료하기 본문

카테고리 없음

[netstat] 포트확인해서 프로세스 종료하기

romeoh 2019. 8. 29. 15:57
반응형

Spring Application 서버가 구동되는 상태에서 예상치 못하게 이클립스가 종료되어

서버를 종료하지 못하면 다시 실행된 이클립스에서 서버를 구동하려 해도 이미 포트가 사용중이라며

서버구동을 못할때가 있습니다.

Caused by: java.net.BindException: Address already in use: bind 
  at sun.nio.ch.Net.bind0(Native Method) 
  at sun.nio.ch.Net.bind(Net.java:433) 
  at sun.nio.ch.Net.bind(Net.java:425) 
  at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) 
  at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) 
  at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210) 
  at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150) 
  at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) 
  at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) 
  ... 19 common frames omitted 
2019-08-29 15:41:54.250 ERROR o.s.b.d.LoggingFailureAnalysisReporter - 

이때 명령어로 Spring Application이 사용하는 포트의 pid를 확인해서 프로세스를 종료하는 방법입니다.

 

스프링을 구동할때 포트를 확인 할수 있습니다.

 

포트확인

########### Mac의 경우
$ lsof -i :"8088"

########### Windows의 경우
$ netstat -ano | find "8088"

PID를 확인합니다.

 

프로세스 종료

########### Mac의 경우
$ kill -9 "40348"
$ lsof -i :"8088"

########### Windows의 경우
$ taskkill /f /pid 40348
$ netstat -ano | find "8088"

kill 명령어로 프로세스를 종료시키고 다시 포트를 확인하면 종료된것을 확인 할 수 있습니다.

반응형
Comments