Is there a way to unbind a port without killing the process bounded to it?

I thought I told nginx to not bind to port 80 by changing all conf files to 8800. But apache says it can't start because port 80 is bound. netstat confirms this.

Is there a way to force nginx to unbind from port 80 without killing the nginx process?


There is no generic way. You have to modify the daemon's configuration file and force it to reload configuration (or restart it).

| improve this answer | |
  • So maybe this is too complicated of a question, but how is the port mapping operationally stored? as in: is the port mapping simply some data structure in RAM under kernel access only? otherwise I would assume that there is some theoretical way for root user to force changes. – Alexander Bird Jan 30 '12 at 4:23
  • Excellent question, but not one I can answer with confidence, sorry. – sendmoreinfo Feb 4 '12 at 11:23

I do not know what distro you have but in a Fedora/RH-based system:

According to /etc/init.d/nginx the service nginx reload sends a HUP signal which is a graceful restart (i.e., will not terminate current sessions but will wait for them to clear).

Equivalent: kill -HUP <nginx pid>

For explanation of the signals that nginx accepts, check this document out.

| improve this answer | |
  • I actually wanted to if there was a general way to unbind ports irrelevant of what the process was. I would have rather eliminated the specifics and kept it general, but oh well. Do you know if I should ask the general question as another question, or revert this question? – Alexander Bird Dec 20 '11 at 4:08
  • 1
    The last line in your question led me to believe that you were targeting nginx specifically. My apologies. Please modify the question to better reflect what you meant to ask. I strongly suspect that there is no way to generally unbind a process from a port without killing the process but I'd be interested to discover otherwise :-). – Belmin Fernandez Dec 20 '11 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.