Open xxnpark opened 2 years ago
sudo fuser -k 80/tcp (혹은 sudo fuser -k 8000/tcp) 사용해보실래요? 같은 에러 만났었는데, 이걸로 해결했던 것 같습니다. https://happist.com/573788/%EC%9B%B9%EC%84%9C%EB%B2%84-%EC%97%90%EB%9F%AC-emerg-bind-to-443-failed-98-address-already-in-use#fuser_-k_80tcp_sayong
또한 nginx를 종료하고 다시 시작하려고 sudo nginx -s stop을 실행해본 결과, nginx.pid 가 발견되지 않는 문제가 있었습니다.
해당 문제는 nginx가 읽어오는 .pid 경로랑 /run.. 경로랑 달라서 발생하는 것 같습니다. 링크 참고 부탁드립니다.
그래서 80번 포트의 사용을 검색해보았더니 nginx worker process가 실행중인 것 같았는데, 그러면 어떻게 nginx를 재시작할 수 있는지 궁금합니다.
이거도 위랑 관련이 있는데, nginx가 본인 worker pid를 제대로 파악하지 못해서 nginx worker가 포트 80을 점유하고 있음에도 다른 프로세스가 쓰는 것으로 인식하는 것 같습니다.
pkill, fuser 등 프로세스를 죽였을때는 80포트가 비게 되지만, restart를 하려할 때는 nginx로 하여금 해당 동작을 실행하려는 것이기 때문에 에러가 나는 것 같습니다.
pid 설정을 재조정하시면 됩니다.
** nginx -s reload 설정을 통해 재시작 없이 변경사항 반영하실 수 있습니다. 근데 이 명령어도 pid 경로 설정을 잘 해주어야 작동하긴 합니다.
sudo fuser -k 80/tcp (혹은 sudo fuser -k 8000/tcp) 사용해보실래요? 같은 에러 만났었는데, 이걸로 해결했던 것 같습니다. https://happist.com/573788/%EC%9B%B9%EC%84%9C%EB%B2%84-%EC%97%90%EB%9F%AC-emerg-bind-to-443-failed-98-address-already-in-use#fuser_-k_80tcp_sayong
@esc5221 넵 가능하긴한데 pkill이랑 같은 방법인것같아서 다른 방법은 없는지 궁금했었습니다..ㅠ 그래도 답변 정말 감사합니다!
@Jhvictor4 답변 감사합니다! pid 관련해서 위 링크도 구글링하면서 봤던 것 같은데 ~nginx가 pid를 어디서 읽어오는지를 모르겠습니다..~
확인해보니 읽어오는 위치와 지정된 위치는 동일한 것 같습니다. 그런데 find
로 nginx.pid
파일을 찾아봐도 전체 디렉토리 내에 존재하지 않는 것 같아 이게 문제일 것 같은데 맞을까요..?
저도 비슷한 문제가 있었는데 그냥 ec2를 재시작했더니 해결 되었습니다.
요약 & 상황
과제 4를 진행하면서
nginx.config
파일 수정 이후 nginx를 재시작하려고 할 때, 80번 포트가 사용중이라며98: Address already in use
에러가 계속해서 발생하고 있습니다.문제 내용
우선
sudo service nginx restart
를 실행하면 다음과 같이 에러가 발생했습니다.에러 내용을 확인해보았더니 포트가 이미 사용중일때 뜨는 98번 에러가 발생함을 확인할 수 있었습니다.
그래서 80번 포트의 사용을 검색해보았더니 nginx worker process가 실행중인 것 같았는데, 그러면 어떻게 nginx를 재시작할 수 있는지 궁금합니다.
또한 nginx를 종료하고 다시 시작하려고
sudo nginx -s stop
을 실행해본 결과,nginx.pid
가 발견되지 않는 문제가 있었습니다.링크와 기타 사이트를 검색해본 결과
ps -ef | grep nginx
을 통해 실행중인 nginx 프로세스를 직접 찾아 kill하거나pkill nginx
로 처리한 뒤 실행하라고 하였는데, 이 방법으로는 nginx를 멈추고 다시 시작하는 것이 가능했습니다. 위의 80번 포트 사용 문제나 pid 파일 미발견 문제는 어떻게 처리해야할까요?