How to kill the port

Sir i was running TCP socket programming but after some time suddenly i got a connection terminated error coming. I was checked that i am able to ping the server IP address(this is end device port will be open always port is 502) but the port was not opening. can u plz help me how to check port is open or not and how to kill the port?

Check the port locally and remotely:

netstat -l -n -p | grep -e 502

after did this command netstat -l -n -p | grep -e 502 nothing is printing. again i am getting this error when i am running my client code.

Failed to connect[] this is my error.

It seems nothing is listening on that port.
Try to restart the service.

what service i need to restart?. Server side i con't do that is end device. mine is client. what should i do from client side.

You need to restart the service running on this host:

Assuming this is the IP you want to connect to.

yes i did restart but not resolving.

Make sure the service process is running:

pgrep -f -a proc_name

not printing.

Check the service log, there could be some error.

1 Like

how to check service log