How can I check if a port is busy or closed?

I'm on Ubuntu 12.04 LTS and this error appeared:

ChannelException: Failed to bind to: 0.0.0.0/0.0.0.0:6702

I need help to check where the problem is.

Can I check if the port are busy or closed? If yes, how ?

Here is my /etc/hosts:

127.0.0.1 localhost
127.0.1.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters 

2 Answers

Ask lsof (man lsof).

sudo lsof -i :6700

Note: Really read man lsof! I'm not sitting at a linux box right now.

0

You can check if the port is in use by running this command.

sudo lsof -i :<Port Number> i am useing 8080 as an example because i have nothing running on port 6700 change 8080 to your port number

sudo lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
havp 1331 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)
havp 25061 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)
havp 25062 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)
havp 25067 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)
havp 25068 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)
havp 25086 havp 3u IPv4 3434363 0t0 TCP 192.168.1.127:http-alt (LISTEN)

or useing this command sudo netstat -tulnp | grep <port number>

neil@AVP:~$ netstat -tulnp | grep 8080
(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)
tcp 0 0 192.168.1.127:8080 0.0.0.0:* LISTEN - 

If the Port has (LISTEN) is indicated that the port is opened. Any port that are not shown in the output indicated that it's closed

Moved from (unformatted) comment by @waltinator:

i tried to use sudo lsof -i :6702 before using it it was empty then when i used it i got this

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3143 st 71u IPv6 12097 0t0 TCP *:6702 (LISTEN) 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like