0

I need to use nc -lp4 5432 --allow 192.168.1.24 but I have a previous nc directive that only has it listening on localhost. It throws an error when I try overwriting it:

$ nc -lp4 5432 --allow 192.168.1.24
Ncat: Got more than one port specification: 4 5432. QUITTING.

How can I overwrite the previous instruction, or delete that listener? I've had a look around and I can't find how to get this removed.

1 Answer 1

3
$ nc -lp4 5432 --allow 192.168.1.24
Ncat: Got more than one port specification: 4 5432. QUITTING.

This has nothing to do with "previous" whatever. The error states that 4 (the option-argument for -p) and 5432 both specify the port, but nc that is about to listen (i.e. with -l) expects at most one port specified in the command line.

If you want to use 5432 and not 4 then either use -p 5432 or don't use -p at all. Any of these will work (one at a time), they are equivalent:

nc -l -p 5432 --allow 192.168.1.24
nc -l -p5432 --allow 192.168.1.24
nc -lp 5432 --allow 192.168.1.24
nc -lp5432 --allow 192.168.1.24
nc -l 5432 --allow 192.168.1.24
10
  • [Mon Jul 11 02:17:11 root@server_n ~] nc -l -p 5432 --allow 192.168.1.24 Ncat: bind to :::5432: Address already in use. QUITTING. The port seems already bound.
    – Rich_F
    Commented Jul 11, 2022 at 6:18
  • 1
  • Interesting there is no command to overwrite or delete it. Thank you.
    – Rich_F
    Commented Jul 11, 2022 at 6:25
  • 1
    @Rich_F A new nc is a standalone process, not a command line interface for some "nc service" that could be reconfigured. Commented Jul 11, 2022 at 6:44
  • 2
    @Rich_F Let's not go chameleon. Ask a new question if you need. I'm not sure what you're describing, maybe this will be a helpful start: your listening nc accepts and processes exactly one connection, then it exits, it's by design. Commented Jul 11, 2022 at 6:50

You must log in to answer this question.

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