Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wat happens if two applications try to listen to the same port?

share|improve this question
The right answer is at – Pacerier Sep 18 '15 at 9:54
up vote 2 down vote accepted

The second one that binds to the port will get an error saying something else is already listening on the port.

share|improve this answer
Does the program check for itself if some other program is listening to the port? – Wintermute Mar 3 '11 at 20:33
The operating system does the check. – carson Mar 3 '11 at 20:41

Unless they are spawned via tcpmux, the first application binds to the port and listens for connections to it, while the second one cannot bind and cannot listen.

share|improve this answer
What is it that prevents the application from binding to the port? – Wintermute Mar 3 '11 at 20:36
When your application makes the relevant system call to "grab" the port, the operating system will "inform" it (via a relevant error code) that it is already taken. – adamo Mar 3 '11 at 21:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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