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 ?



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
  • thanks for following up. Could you explain why did this work? – Aquarius_Girl Feb 26 '13 at 10:36

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.