netcat -ul -p2115 fails with a usage statement.

What am I doing wrong?


3 Answers 3


To quote the nc man page:

-l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options. Additionally, any timeouts specified with the -w option are ignored.

The key here is that -p cannot be combined with the -l flag. When using the -l flag, any ports specified in the positional arguments are used. So instead, you could use the following:

netcat -ul 2115

-p is wrong. This will work on RedHat- and Debian-based distros:

nc -u -l 2115

For some reason, Andrew's solution didn't work for me. With further research, I learned that we need to add -p flag when working locally. So the following command worked for me.

 nc -ulp 2115
  • 12
    Probably becuase there's two separate and subtly incompatible implementations of netcat in common use.
    – womble
    Jul 17, 2018 at 0:21
  • I also had this problem on debian stretch. The version of netcat installed was 1.10-41.
    – Ben Burns
    Apr 24, 2020 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .