Some times whenever I restart the application, which is built on
Java
Struts
Mysql and Jboss 4.05 Version
I get the error as Address already in use: JVM_Bind
Only fix that i know is to restart the machine and try again, it will work.
Else Some times I do Ctrl-Alt-Del and Stop all the process related to Java, some times this also works.
But what is the exact reason and how can we prevent this problem ?
asked May 5, 2010 at 11:25
1
Address already in use: JVM_Bind
means that some other application is already listening on the port your current application is trying to bind.
what you need to do is, either change the port for your current application or better; just find out the already running application and kill it.
on Linux you can find the application pid by using,
netstat -tulpn
answered May 5, 2010 at 11:34
phoenix24phoenix24
2,0622 gold badges20 silver badges24 bronze badges
6
In windows this scenario happens when Eclipse crashes without a clean shutdown it will have the local Jetty or Tomcat server keep running.
When you reopen Eclipse and try to start server again this will lead to the «Address already in use: JVM_Bind»
You can solve this by opening Task Manager and find the javaw.exe process and ending it.
Then you can restart the server on Eclipse.
answered Feb 19, 2015 at 23:37
CodeQCodeQ
4535 silver badges8 bronze badges
1
On windows, in an elevated cmd/ps
net stop winnat
then
net start winnat
Resets the windows’ NAT service and that removes faulty listeners.
This method works for most ‘cannot listen on this port’ errors, like as in Docker, JVM etc.
answered Jan 9, 2022 at 11:45
cryocryo
3692 silver badges5 bronze badges
I usually come across this when the port which the server (I use JBoss) is already in use
Usual suspects
- Apache Http Server => turn down the service if working in windows.
- IIS => stop the ISS using
- Skype =>yea I got skype attaching itself to port 80
To change the port to which JBoss 4.2.x binds itself go to:
«C:jboss4.2.2serverdefaultdeployjboss-web.deployerserver.xml»
here default is the instance of the server
change the port here :
<Connector port=»8080″
address=»${jboss.bind.address}» >
In the above example the port is bound to 8080
answered May 5, 2010 at 15:10
1
Open command line and type: netstat -a -o -n
or tasklist
to see currently running processes.
Find port that related to Java and type: taskkill /F /PID <your PID number>
.
Click Enter.
answered Apr 16, 2018 at 15:26
Taras MelnykTaras Melnyk
2,9473 gold badges36 silver badges34 bronze badges
Is it possible that MySql listening on the same port as JBoss?
Is there a port number given in the error message — something like Address already in use: JVM_Bind:8080
You can change the port in JBoss server.xml to test this.
answered May 5, 2010 at 11:48
JoseKJoseK
31k14 gold badges102 silver badges131 bronze badges
For the sake of completeness as many may fall in this SO for other reasons than OP’s question, here is another info that saved my day :
TL;DR;
Check that the port you want to open is not reserved (even though no application has opened it)
On windows :
netsh interface ipv4 show excludedportrange protocol=tcp
Explanation :
At least on windows, another possible cause for the java.net.BindException: Address already in use: JVM_Bind
is that the operating system has «reserved» the port.
If you use the commands from other answer in this topic, they will tell you that no application is listening to the port, yet you cannot open it.
Some windows update like this one reserves range port that can then no longer be claimed by processes.
Though not explicit on the port that can no longer be opened, the update note mentions a command that can help troubleshooting the issue :
netsh interface ipv4 show excludedportrange protocol=tcp
this will yield a list of port range that are blocked :
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
5357 5357
49709 49808
49809 49908
49909 50008
50009 50108
50109 50208
50280 50379
* - Administered port exclusions.
answered Apr 28, 2022 at 8:18
GhurdylGhurdyl
1,0271 gold badge13 silver badges18 bronze badges
The quick answer on how to prevent it is that you most likely need to stop JBoss before starting it again.
You should be able to call the «Terminate» button in the Console view to shutdown the server.
answered May 5, 2010 at 11:28
Jarle HansenJarle Hansen
1,9812 gold badges16 silver badges28 bronze badges
1
That error means that the you are trying to create a new ServerSocket
on a port already in use by another ServerSocket
. So try to make your application closing all sockets and connections you know about and be sure your application is completely terminated. Also check if there is another proces you launched by your program.
answered May 5, 2010 at 12:40
Martijn CourteauxMartijn Courteaux
66.8k46 gold badges194 silver badges285 bronze badges
It can be also caused by double definition of port 8080 in ..tomcatconfserver.xml :
<Connector port="8080"
enableLookups="false" redirectPort="8443" debug="0"/>
<Connector port="8080"
enableLookups="false" address="127.0.0.1" maxParameterCount="30000"/>
answered Jan 29, 2014 at 10:52
SzBSzB
9679 silver badges12 bronze badges
0
please try following options for JVM binding exception:
- start and stop the server. and check the server process ids and kill and stop the server.
- go to control panel->administrative tool-> service-> check all server and stop all the servers and then start your own server.
- change the Browser which your using. for example if
your using IE ,change it to Mozilla firefox.
Lucifer
29.2k24 gold badges90 silver badges141 bronze badges
answered May 11, 2012 at 9:07
I was having this problem too. For me, I couldn’t start/stop openfire (it said it was stopped, but everything was still running)
sudo /etc/init.d/openfire stop
sudo /etc/init.d/openfire start
Also, restarting apache did not help either
sudo /etc/init.d/apache2 restart
The errors were inside:
/opt/openfire/logs/stderror.log
Error creating server listener on port 5269: Address already in use
Error creating server listener on port 5222: Address already in use
The way I fixed this, I had to actually turn off the server inside the admin area for my host.
answered Jun 14, 2013 at 17:20
I had the same on Windows. My solution was to get which port the debug wants to connect to. (In IntelliJ a red rectangle already giving the info: «Error running Tomcat: Unable to open debugger port (127.0.0.1:XXXXX): … Already in use…»)
Let’s say XXXXX is the port number.
Then i searched for the problem and the PID in a cmd window:
netstat -ano | find "CLOSE_WAIT" | find ":XXXXX"
I got the PID number as the last number in the result line. (Let’s say YYYY)
Finally:
TASKKILL /PID YYYY
An extra info: Winscp logged out meanwhile, probably it was causing my problem.
answered Apr 20, 2016 at 12:05
BlondCodeBlondCode
3,9191 gold badge19 silver badges18 bronze badges
This recently happen to me when enabling JMX on two running tomcat service within Eclipse. I mistakenly put the same port for each server.
Simply give each jmx remote a different port
Server 1
-Dcom.sun.management.jmxremote.port=9000
Server 2
-Dcom.sun.management.jmxremote.port=9001
answered May 31, 2017 at 16:34
stevesteve
1,7661 gold badge15 silver badges29 bronze badges
You can try deleting the Team Server credentials, most likely those will include some kind of port in the server column.
Like https://wathever.visualstudio.com:443
Go to Windows/Preferences
expand Team then Team Foundation Server
go to Credentials and remove whichever is there.
answered Jul 26, 2018 at 11:13
On Mac, even when I’d search with netstat
, no processes were binding to that port, but I’d still get the «Address already in use» Bind exception.
In this case, going into
Safari -> Preferences -> Privacy -> Manage Website Data… -> finding «localhost» -> Remove
fixes the problem, if there really is no process running with that port. It seems Safari’s web cache maintains a reference to the port somehow, and removing that cache frees up the port.
answered Apr 21, 2021 at 7:40
EpagaEpaga
37.7k58 gold badges156 silver badges245 bronze badges
Sometimes, I use lsof -i:8080
and I get nothing back, no pid. Well something has to be taking place. If this is your case, it could be docker. By using docker ps
you can check if you have any old dockers lying around and kill them. This could be the culprit for a port already in use error.
answered Jul 15, 2021 at 13:44
In Eclipse, I got this error:
run:
[java] Error creating the server socket.
[java] Oct 04, 2012 5:31:38 PM cascadas.ace.AceFactory bootstrap
[java] SEVERE: Failed to create world : java.net.BindException: Address already in use: JVM_Bind
[java] Java Result: -1
BUILD SUCCESSFUL
Total time: 10 seconds
I’m not sure why it came up now, but it ran fine just a few hours ago. Do I need to restart my machine? How do i get to the bottom of it? I appreciate any tips or advice.
asked Oct 4, 2012 at 23:07
CaffeinatedCaffeinated
11.7k39 gold badges117 silver badges214 bronze badges
2
If you know what port the process is running you can type:
lsof -i:<port>
.
For instance, lsof -i:8080
, to list the process (pid) running on port 8080.
Then kill the process with kill <pid>
biniam
8,0318 gold badges48 silver badges57 bronze badges
answered Oct 4, 2012 at 23:20
5
Yes you have another process bound to the same port.
TCPView (Windows only) from Windows Sysinternals is my favorite app whenever I have a JVM_BIND error. It shows which processes are listening on which port. It also provides a convenient context menu to either kill the process or close the connection that is getting in the way.
informatik01
15.8k10 gold badges74 silver badges103 bronze badges
answered Oct 5, 2012 at 0:13
Guido SimoneGuido Simone
7,8722 gold badges19 silver badges21 bronze badges
3
In windows
netstat -ano
will list all the protocols, ports and processes listening .
Use
taskkill -pid "proces to kill" /f
to kill the process listening to the port.
e.g
taskkill -pid 431 /f
answered Oct 1, 2014 at 18:00
AbhiAbhi
6,4016 gold badges40 silver badges57 bronze badges
2
In Ubuntu/Unix we can resolve this problem in 2 steps as described below.
-
Type
netstat -plten |grep java
This will give an output similar to:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1001 76084 9488/java
Here
8080
is the port number at which the java process is listening and9488
is its process id (pid). -
In order to free the occupied port, we have to kill this process using the
kill
command.kill -9 9488
9488
is the process id from earlier. We use-9
to force stop the process.
Your port should now be free and you can restart the server.
answered Jun 4, 2016 at 5:45
Bharti RawatBharti Rawat
1,93119 silver badges32 bronze badges
2
In Mac:
Kill process
Terminal: kill <pid>
Find pid:
Terminal: lsof -i:<port>
From Diego Pino answer
answered Mar 1, 2013 at 8:46
HoyinHoyin
5195 silver badges6 bronze badges
2
(Windows Only)
To kill a process you first need to find the Process Id (pid)
By running the command :
netstat -ano | findstr :yourPortNumber
You will get your Process Id (PID), Now to kill the same process run this command:
taskkill /pid yourid /f
answered Jun 25, 2018 at 8:35
1
For windows :
-
Find the process id
netstat -nao | find «8080»
It will show you the process ID as a number.
Example:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 18856
Here 18856 is the process ID
-
Kill that process
taskkill /PID 18856 /F
Output : SUCCESS: The process with PID 18856 has been terminated.
Here using taskkill you are killing the process ID:18856
For linux/Mac:
sudo kill -9 $(sudo lsof -t -i:8080)
Here you find the process by port 8080 using sudo lsof -t -i:8080
and killing it by sudo kill command
answered Apr 29, 2020 at 8:06
You have another process running on the same port.
You could try killing one of the java.exe services running in your task manager — ps make sure you dont kill eclipse since that is listed as java.exe as well. If nothing else works, restarting your machine will fix it anyhow. It looks like youre not shutting down a socket from a previous test. Hope this helps.
answered Oct 4, 2012 at 23:11
javarebeljavarebel
1601 silver badge9 bronze badges
0
For those who are looking for the simplest of the answers (as that is what we usually miss), just stop your running project and start it again.
Most of the time what we do is we forget to stop the project we ran earlier and when we re-run the project it shows such an issue.
I am also attaching a photo to make it clearer (I use ‘Spring tool suite’).
So what you need to do is either click the button on the extreme right, if you want to relaunch the same project or first click on the button which is 2nd from the right to stop your project and then the button on the extreme left to run your project. I hope this will solve the issue of few of the newer programmers.
answered Feb 24, 2017 at 7:46
In Windows CMD line, find out the Process ID that hold a connection on the bind port by entering following command:
C:> netstat -a -o
-a show all connections
-o show process identifier
And then Terminate the process.
answered Aug 17, 2015 at 8:15
CharlesXCharlesX
1281 silver badge7 bronze badges
You need to close your port
if you are a linux user then type
fuser -k 8080/tcp
Suraj Rao
29.3k11 gold badges96 silver badges103 bronze badges
answered Nov 1, 2018 at 6:43
This BindException would come when another process is already running in the specified port(8080).
You can use anyone of the following approach.
-
Change the server port: If you are using Tomcat server and IntelliJ IDE, you can configure the server port by configuring the tomcat server
or
- Go to tomcat>conf folder
- Edit server.xml
- Search «Connector port»
- Replace «8080» by your port number
- Restart tomcat server.
- Kill the existing running process in that port and start the server.
For Linux/Mac
sudo kill -9 $(sudo lsof -t -i:8080)
For Windows
netstat -ano | findstr :8080 taskkill /PID typeyourPIDhere /F
Note: (/F forcefully terminates the process)
answered Aug 17, 2021 at 7:58
Yes, as Guido Simone said it because another process listening to the same port.If you are in Ubuntu You can simply kill that process giving command
sudo kill $(sudo lsof -t -i:[port number])
ex: sudo kill $(sudo lsof -t -i:8080)
But once it didn’t work for me.
i gave the command
$ lsof -i:[port]
and it shows nothing.
I checked my docker containers using command
docker ps -a
but non of them alive.All containers has stopped
(but i remember ,i stopped one container which was used same port few minutes ago.).To make sure that docker is not the reason,I stop whole docker process using command sudo service docker stop
and try again.
Surprisingly eclipse didn’t show the error at that time .It run my program perfectly.
Hope my experience will help some one.
answered Sep 3, 2017 at 7:39
Yasitha BandaraYasitha Bandara
1,7952 gold badges12 silver badges20 bronze badges
The port is already being used by some other process as @Diego Pino said u can use lsof on unix to locate the process and kill the respective one, if you are on windows use netstat -ano to get all the pids of the process and the ports that everyone acquires. search for your intended port and kill.
to be very easy just restart your machine , if thats possible
answered Oct 5, 2012 at 0:08
Akash YadavAkash Yadav
2,40020 silver badges32 bronze badges
Restart the PC once, I think it will work. It started working in my case. One more thing can be done go to Task Manager and End the process.
answered May 16, 2018 at 8:57
KumarKumar
4121 gold badge9 silver badges18 bronze badges
1
In my case Tomcat was running in a background. I’ve installed it as a external servlet while using Eclipse.
With a Spring Boot in Intellij it has it own server but cannot start while it’s already occupied.
In my case Tomcat starts automatically I turn on my OS, that is why I need to shut down him manualy:
$ sudo service tomcat stop
of course «tomcat» depends what version of tomcat you are using.
Hope it might help to someone.
answered Oct 15, 2019 at 10:25
EnGoPyEnGoPy
1932 silver badges13 bronze badges
I faced similar issue in Eclipse when two consoles were opened when I started the Server program first and then the Client program. I used to stop the program in the single console thinking that it had closed the server, but it had only closed the client and not the server. I found running Java processes in my Task manager. This problem was solved by closing both Server and Client programs from their individual consoles(Eclipse shows console of latest active program). So when I started the Server program again, the port was again open to be captured.
answered Jul 18, 2016 at 10:17
Your port must be busy in some Other Process. So you can download TCPView on https://technet.microsoft.com/en-us/sysinternals/bb897437 and kill the process for used port.
If you don’t know your port, double click on the server that is not starting and click on Open Server Properties Page and click on glassfish from left column. You will find the ports here.
answered Aug 18, 2016 at 8:01
suketupsuketup
4597 silver badges12 bronze badges
(1) check the port is in use or not, kill that process
$ lsof -i:[port]
(2) another reason is the port is used by ipv6, solution:
edit /etc/sysctl.conf
add this to the file
net.ipv6.conf.all.disable_ipv6 = 1
then make it effect
$ sudo sysctl -p /etc/sysctl.conf
or just reboot
answered Feb 17, 2017 at 17:43
tonysoktonysok
6271 gold badge7 silver badges13 bronze badges
It means some other process is already using the port. In case if this port is being used by some other critical applications and you don’t want to close that application, the better way is to choose any other port which is free to use.
Configure your application to use any other port which is free and you will see your application working.
answered Jan 31, 2018 at 7:32
You can close every Java Process and start again your app:
taskkill /F /IM java.exe
start your app again…
answered Sep 28, 2020 at 23:08
I actually just used the Terminate button in Console Tab. It’s a small red box. Hope that hepls.
answered Apr 12, 2022 at 13:06
1
- HowTo
- Java Howtos
- Address Already in Use JVM_Bind Error in …
Sheeraz Gul
Jul 25, 2022
This tutorial demonstrates Java’s address already in use jvm_bind
error.
the Address already in use: JVM_Bind
Error in Java
The Address already in use: JVM_Bind
mostly occurs when we work on web applications. This error is common when using services like Tomcat, Struts, JBoss etc.
The error occurs when we try to bind with a port on which some other application is already listening. To solve this issue, either we have to change the port for the current application or kill the other application running on the same port.
Here is the solution for both scenarios.
Change the Web Server to Run on Another Port
Changing the web server port is an easy task in most scenarios. For example, if you are using Tomcat, follow the process below to change the web server port.
-
Find the file
server.xml
, usually in the directoryC:/apache-tomcat-7.0.11/conf/server.xml
. -
The file
server.xml
will be a code snippet, as shown below.<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
- Now, change the connector port number to any other port number and save it.
- Now, the web server will run on the port number you have given. The error
Address already in use: JVM_Bind
is solved.
Kill the Previous Service
We can also kill the previous application running on the port to run our application on that port. To do that, we have to find the process in which the service is running and then kill that service.
Here is the process to find and kill the services on Windows and Linux platforms.
For Windows:
-
First, find the process using your port number. Use the following command.
netstat -ano | find "8080"
-
The command above will find the process running on the port
8080
. Now, for example, the process found is1234
. -
Kill the process
1234
by using the following command.
- The
taskkill
command will kill the process with process id1234
. - Now, we can run our application on the port
8080
without theAddress already in use: JVM_Bind
error.
For Linux:
-
Similarly, the
netstat
command is also used in Linux to find a service or process. -
The
netstat
is used to show the status of the network, and thegrep
command is used to find the process running on a port. See the command below.netstat -an | grep "8080"
-
The command above will find the process running on the port
8080
. Now, for example, the process found is1234
. -
Use the
kill
command to kill the1234
process. -
The
Address already in use: JVM_Bind
error will be solved after running these commands in Linux.
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn
Facebook
Related Article — Java Error
- Java.Lang.VerifyError: Bad Type on Operand Stack
- Error Opening Registry Key ‘Software JavaSoft Java Runtime Environment.3’ in Java
- Identifier Expected Error in Java
- Error: Class, Interface, or Enum Expected in Java
- Unreported Exception Must Be Caught or Declared to Be Thrown
- Java.Lang.OutOfMemoryError: Unable to Create New Native Thread
Have you got “java.net.BindException: Address already in use: JVM_Bind” when you start JBoss or WildFly ? Here’s how to solve it.
The most likely option is that you have still one instance of JBoss running, maybe because of an unclean shutdown. Firstly, check from the Windows Task Manager or (Unix User that you don’t have any JBoss server running.
$ pgrep -f jboss 6085
Next, if you cannot find any running JBoss instance, then there’s a process which has stolen some of JBoss default ports. The Ports number used by JBoss / WildFly are quite different, depending on the version of the application server you are using. The following section will list all the ports open by each application server version:
Ports used by WildFly / JBoss EAP 7
Port |
Description |
8080/8443 |
HTTP/HTTPS Service |
9080/9993 |
Management / Secured Management |
8009 |
AJP protocol (“ha” profiles) |
Ports used by JBoss AS 7 / EAP 6
Port |
Description |
8080/8443 |
HTTP/HTTPS Service |
9080 |
Management Service (Admin Console) |
9999 |
Management Service (CLI) |
4447 |
Remoting |
5445 |
Messaging ( Full Profile) |
8009 |
AJP protocol (For HA Profiles) |
Ports used by JBoss AS 5
Port |
Description |
1098,1099 |
HTTP Naming |
3873 |
DefaultEjb3Connector |
4444,4445,4446 |
EJB RMIObjectPort |
8080 |
HTTP Service |
8009 |
AJP protocol |
8009 |
AJP protocol (Not active by default) |
8083 |
Web services |
8090,8092,8093 |
JMS ServerBindPort |
Unix users:
In most Linux distributions you can use the following command to find PID-Process Name information for one user:
$ netstat -tulpn | grep 8080 tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 22005/java
Another powerful tool is fuser which can check the processes using TCP/UDP sockets. Here is how to check which process binds a TCP Socket on port 8080:
$ fuser -v -n tcp 8080
Windows users:
You can use netstat to get network information for all processes. In the following example we make a filter on port 8080:
netstat -ano | find "8080"
You will be able to detect the process that is engaging your Port. Assuming that your PID is 1234, in order to kill it you can execute:
taskkill -pid 1234 /f
You can also use the TaskManager to kill your process. Mind it: by default the Task Manager doesn’t show the PID. You have to add it from the menu View | Select columns)
If you are using older versions of JBoss, chances are that MS Office or MS OfficeCommunicator are engaging port 1098 and 1099. If you don’t want to shut down these tools then your only option is using a different bind address
Mac Users:
Find pid by executing from the Terminal:
lsof -i:<port>
Kill the process with:
kill <pid>
java.net.BindException: Cannot assign requested address:
This means that you probably are not using a correct address for one of your network interfaces configured in the application server. If you boot the application server assigning an host name:
$ ./standalone.sh -b hostname
Then the file /etc/host in both Windows and Linux is used to resolve domain name into IP address, if this mapping is incorrect than you will get java.net.BindException: Cannot assign requested address: JVM_Bind.
See also this tutorial for more information about JBoss port configuration.
Post Views:
2,240