7

Server side:

nc -l -p 192.168.1.229 1234

Client side:

nc 192.168.1.229 1234

But it cannot connect. Why?

~# nc 192.168.1.229 1234
(UNKNOWN) [192.168.1.229] 1234 (?) : Connection refused
2
  • It is unclear whether the server and client are on the same machine, on two different machines on the same network, or on two different machines on two different networks.
    – Kusalananda
    Commented Aug 25, 2021 at 6:37
  • If you find a good suggestion, please share with us. I don't see the accepted answer.
    – Cloud Cho
    Commented May 6 at 20:32

3 Answers 3

15

On the server side you shouldn't provide its IP address.

Server side should be:

nc -l -p 1234

Client side should be

nc 192.168.1.229 1234

Note that the source of the problem might be a firewall/router between those two machines which filter-out traffic on the port you are using.

8
  • yeah. I have tried this also. server side: nc -l -p 1234 and client side: nc 192.168.1.229 1234. But again it shows same output.
    – vijaya
    Commented May 15, 2017 at 7:03
  • please suggest me what to do?
    – vijaya
    Commented May 15, 2017 at 7:07
  • @vijaya do you execute the client & server on the same machine or on two different machines?
    – Yaron
    Commented May 15, 2017 at 7:18
  • on 2 different machines.
    – vijaya
    Commented May 15, 2017 at 9:05
  • @vijaya - is it possible that there is a firewall/router between those two machines which filter-out traffic on the port you are using?
    – Yaron
    Commented May 15, 2017 at 9:07
-1

Open a terminal and type this "nc" cmd to start a server to listen :

nc -l -p 4545

Now a server is created and its listening for a connection through the port 4545.

Note: Instead of 4545 you can give any value in the range 1024 to 65535. The first 1024 port numbers (0-1023) are already reserved.

Open another terminal and type the following command to set client connection:

nc 127.0.0.1 4545

Now the client has been connected to the server listening at the port number 4545.You can just type anything from the client console(terminal) which will be echoed in the server side, and vice-versa.

If you want to terminate the connection, just press Ctrl+c in any one the terminal.

Note: The IP address 127.0.0.1 is called the loopback address. You should not change it. Otherwise it won't work.

1
  • Kind confusing...if you put loop back, 127.0.0.1, in the client side, doesn't client talk herself instead of the server?
    – Cloud Cho
    Commented May 6 at 20:32
-3

if you use kali vmware, it's like my case. Please change network, avoid NAT network, it doesn't allow tunneling, or error.. Thank

1
  • Would you add details for "change network"? Why?
    – Cloud Cho
    Commented May 6 at 20:27

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