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?

link|improve this question

71% accept rate
feedback

2 Answers

up vote 3 down vote accepted

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

link|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. – Thr4wn Jan 30 at 4:23
Excellent question, but not one I can answer with confidence, sorry. – sendmoreinfo Feb 4 at 11:23
feedback

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.

link|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? – Thr4wn 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 :-). – Beaming Mel-Bin Dec 20 '11 at 4:15
feedback

Your Answer

 
or
required, but never shown

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