50

This question already has an answer here:

I am trying to run weblogic server on my linux machine and I am getting the following error :

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

I think that the error means that the debugger port which by default is 8453 is already held by some other service . How can I find out what service is runnning in a partcular port number ?

P.S: I used netstat command but that shows all the services occupying all ports ..here I am interested in a particular port only.

marked as duplicate by Eric Renouf, mdpc, G-Man, Anthon, Anthony Geoghegan Sep 28 '16 at 8:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • And you don't want to use grep because of? – scai Jan 23 '13 at 9:18
  • @scai I am new to Linux world. I can ofcourse use the grep command but wanted to find out if there could be a easier way than doing a grep on the output of netstat – Geek Jan 23 '13 at 9:52
55

Two ways:

  • lsof -i :port -S
  • netstat -a | grep port

You can do man lsof or man netstat for the needed info. Replace port by the port number you want to search for.

  • 2
    You may want to make that netstat -a | grep portnumber. Otherwise you will be at the mercy of /etc/services. – a CVn Jan 23 '13 at 9:42
  • lsof seems to be the most used :) – Aura Sep 4 '14 at 6:44
  • I found that for port 80 I needed higher privileges to see the listing: sudo lsof -i :80 -S. I would guess this is true for any restricted-use port (those at or below 1024 if I remember correctly). – amacleod Nov 18 '14 at 19:39
  • Thanks for the answer. It really helped. First when I tried this command on my CentOS, I got the error as Command Not Found. Hence I installed them and used the command. For those who are facing the same issue. For Ubuntu: sudo apt-get install lsof - Installs lsof. If you want to install netstat, then the command is sudo apt-get install netstat. For CentOS: sudo yum install lsof and for netstat installation sudo yum install netstat. Note: Usually Ubuntu comes by default installed with these packages. – Vinod Tigadi Jun 2 '15 at 10:55
11

You can use fuser or lsof i.e:

fuser 8453/tcp
lsof -i TCP:8453

If you want more information from fuser you can also use the -v flag, i.e: fuser -v 8453/tcp

  • I ca not issue either command . I can see the man pages but when I issued the command I get a "lsof: Command not found.". Similar case with fuser also . – Geek Jan 23 '13 at 10:50
  • @Geek you may have to either install the packages or specify the full path depending on your setup. – Ulrich Dangel Jan 23 '13 at 11:48
  • I have no option of installing anything on this machine . Which full path are you talking about ? How can I see it ? Can you please put that information in the answer itself ? – Geek Jan 23 '13 at 15:21
  • At least lsof is commonly only easily available to the system administrator, by virtue of being placed in one of the sbin directories. Try sudo -i followed by the lsof command, and see if that works better. – a CVn Jan 23 '13 at 15:32
  • 1
    Neither lsof nor fuser are installed by default in Fedora. – vonbrand Jan 26 '13 at 7:09
8

for what its worth... depending on the version of netstat (specifically GNU netstat) you have, you can use

netstat -punta | grep <port>

this will show you connections in ESTABLISHED and LISTEN states UDP and TCP and it will ignore the UNIX local sockets. the end result is a nice, neat, small result set.

the -p flag will give you the process ID and the process name of whatever is using that port

the -u flag shows udp

the -n flag is for numerical addresses

the -t flag shows tcp

the -a shows listening and non-listening sockets

3

On centos

/usr/sbin/lsof -i tcp:8453 (lsof -i protocol:port)

On ubuntu

/usr/bin/lsof -i tcp:8453

Or, narrow results of netstat using filters.

Not the answer you're looking for? Browse other questions tagged or ask your own question.