Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I'm trying to use nc to debug some network issues (but am sort of ending up debugging nc itself).

I have the relevant port open (to the world) in the ec2 security group. When I run either of these commands on my ec2 server:

nc -n -v -v -l <private IP address> -p 4161


nc -n -v -v -l <public IP address> -p 4161

And then from any other server (on EC2 or in my local office network):

nc -n -v -v <public IP address> 4161

I get the following on the server (which then exits):

listening on [any] 4161 ...
invalid connection to [<private IP address>] from (UNKNOWN) [<remote IP address>] 54002

And on the client (which also then exits):

(UNKNOWN) [<public IP address>] 4161 (?) open
sent 0, rcvd 0

Any suggestions?

I suspect this has to do with the fact that EC2 instances have public and private IP addresses, but I'm baffled as to how to get this to work ?

share|improve this question
up vote 2 down vote accepted


Never fails. As soon as I post a question to serverfault, a moment later I find the answer myself...

Omitting the IP address for the server netcat takes care of it:

nc -n -v -v -l -p 4161
share|improve this answer
thanks for following up. Could you explain why did this work? – TheIndependentAquarius Feb 26 '13 at 10:36

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.