2013/01/24

(98)Address already in use: make_sock: could not bind to address [::]:80


서버 운영중에 아파치가 이상동작을 하며 프로세스 실행 시 아래와 같은 에러를 뱉을 경우

httpd (을)를 시작 중: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [실패]

이미 어떤 프로세스가 80포트를 점유하고 있으니 같은 포트로 아파치 소켓을 열 수 없다는 말인데, 원인은 좀 더 찾아봐야겠지만 해결방안은 비교적 간단하다.

일단 실행중인 httpd 프로세스를 모두 강제 종료 시킨 후

$ ps ax | grep httpd | awk '{print $1}' | xargs kill

지금 80포트로 바인딩되어있는 프로세스를 확인하고 이 또한 종료시킨다.

$ netstat -nlp | grep :80

$ kill -9 {해당 프로세스 아이디}

이제 다시 아파치를 시작해보면

$ sudo /etc/init.d/httpd start
httpd (을)를 시작 중:                                      [  OK  ]

이상입니다.