cannot start Tomcat 7 server - java.net.BindException: Address already in use
Asked Answered
M

13

22

Hi i am not able to start tomcat 7 server from eclipse.

When i give start from eclipse i get the following error log.

Jan 11, 2013 10:10:27 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Jayant\Desktop\data\adt-bundle-windows-x86\eclipse;;.
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1165 ms
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:28 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 507 ms
Jan 11, 2013 10:10:28 AM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]: 
java.net.BindException: Address already in use: JVM_Bind
    at java.net.DualStackPlainSocketImpl.bind0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
    at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
    at java.net.PlainSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.bind(Unknown Source)
    at java.net.ServerSocket.<init>(Unknown Source)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:422)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:707)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:653)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)

Jan 11, 2013 10:10:28 AM org.apache.coyote.AbstractProtocolHandler pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:29 AM org.apache.coyote.AbstractProtocolHandler pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:10:30 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jan 11, 2013 10:10:30 AM org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:10:30 AM org.apache.coyote.AbstractProtocolHandler stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]

Now i am getting the following error.

Jan 11, 2013 10:18:59 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Jayant\Desktop\data\adt-bundle-windows-x86\eclipse;;.
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:19:00 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 872 ms
Jan 11, 2013 10:19:00 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 11, 2013 10:19:00 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 11, 2013 10:19:00 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 11, 2013 10:19:00 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 535 ms
Jan 11, 2013 10:20:13 AM org.apache.catalina.core.StandardServer await
WARNING: StandardServer.await: Invalid command 'GET / HTTP/1.1' received
Jan 11, 2013 10:20:19 AM org.apache.catalina.core.StandardServer await
WARNING: StandardServer.await: Invalid command '' received
Magnetometer answered 11/1, 2013 at 4:44 Comment(0)
A
17

The admin port is for receiving admin commands,and the HTTP port is for receiving HTTP requests. You must use different ports. What happened is: the HTTP connector could not start, because the server already opened that port. Your browser/client/whatever sent the request to the admin port , the server does not understand HTTP and logs this error.

Try Reinstalling Tomcat to another port.

Acalia answered 11/1, 2013 at 4:46 Comment(13)
now i am getting the following error @Neurenor. see the edited codeMagnetometer
try localhost:8080 in your browser.Acalia
try reinstalling tomcat and give port number at installation time.Acalia
hmmm i installed tomcat from eclipse itself. did add new server and download and install it didnt ask me the port number.Magnetometer
try installing tomcat outside the eclipse and it will ask you.and set your tomcat installation directory to eclipse.Acalia
i have given server shutdown port as 8005, HTTP/1.1 Connector port as 8080 and AJP/1.3 Connector port as 8009 is it alright??Magnetometer
it is better that you set connector port to 8081 or 8082 etc.Acalia
hi its working but how to start it in eclipse when i do right click in servers console and give new server and try to click tomcat 7 nothing happens. I am using this tutorial codeoncloud.blogspot.in/2012/12/…Magnetometer
#14230247Acalia
refer above question it might help you.Acalia
Several ports (8080, 8082) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).Magnetometer
i am getting the following error when i try 2 start from eclipse.Magnetometer
stop it from outside of eclipse.as a suggested before.Acalia
A
33

Go to server.xml file and change

<Server port="8005" shutdown="SHUTDOWN">

to

<Server port="8006" shutdown="SHUTDOWN">
Agraphia answered 9/7, 2019 at 18:39 Comment(0)
A
17

The admin port is for receiving admin commands,and the HTTP port is for receiving HTTP requests. You must use different ports. What happened is: the HTTP connector could not start, because the server already opened that port. Your browser/client/whatever sent the request to the admin port , the server does not understand HTTP and logs this error.

Try Reinstalling Tomcat to another port.

Acalia answered 11/1, 2013 at 4:46 Comment(13)
now i am getting the following error @Neurenor. see the edited codeMagnetometer
try localhost:8080 in your browser.Acalia
try reinstalling tomcat and give port number at installation time.Acalia
hmmm i installed tomcat from eclipse itself. did add new server and download and install it didnt ask me the port number.Magnetometer
try installing tomcat outside the eclipse and it will ask you.and set your tomcat installation directory to eclipse.Acalia
i have given server shutdown port as 8005, HTTP/1.1 Connector port as 8080 and AJP/1.3 Connector port as 8009 is it alright??Magnetometer
it is better that you set connector port to 8081 or 8082 etc.Acalia
hi its working but how to start it in eclipse when i do right click in servers console and give new server and try to click tomcat 7 nothing happens. I am using this tutorial codeoncloud.blogspot.in/2012/12/…Magnetometer
#14230247Acalia
refer above question it might help you.Acalia
Several ports (8080, 8082) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).Magnetometer
i am getting the following error when i try 2 start from eclipse.Magnetometer
stop it from outside of eclipse.as a suggested before.Acalia
C
12

In Windows 10 port 8005 is already reserved (for something). Change to for example 8089 (or any free port) in tomcat/conf/server.xml

Calefactory answered 2/10, 2020 at 11:16 Comment(0)
S
6

use:

pkill -f tomcat

to get rid of any existing or un-responsive tomcat instances or processes.

start tomcat. 
Simonetta answered 15/10, 2018 at 23:29 Comment(1)
Please mention this is only for linux.Fillbert
A
4

I was having this problem (port 8005 already being used) and the root cause was due to an existing tomcat process already running on my machine. So, what I needed to do was basically kill the existing process and start up tomcat again.

Alcinia answered 14/8, 2013 at 13:37 Comment(0)
D
4

The common mistake is to use the same Shutdown and Connector port in your server.xml configuration file.

These ports should be different and here is the right example:

<Server port="8005" shutdown="SHUTDOWN">
    <Connector port="8983" protocol="HTTP/1.1"

By default Tomcat listens on port 8005 for SHUTDOWN command and it should be always different to Connector port.

If your port is still already in use, try sudo lsof -i:8005 for finding why.

Diffuse answered 6/4, 2015 at 21:2 Comment(0)
H
2

If you have multiple apps, check if any of the other apps use the same server port defined in the server.xml file. This was the case for me.

Hume answered 24/12, 2021 at 17:28 Comment(0)
O
1

If you are using linux system, then type ps -ef|grep tomcat on terminal. Then find the process id(PID). then type kill -9 on the terminal. Now , start the tomcat server.

Octavus answered 21/6, 2018 at 16:30 Comment(0)
A
1

2 ways to solve this issue:

1> Go the tomcat server installation directory and open the server.xml file, check if the

Connector and server ports are different. If not make them different ports and then check if nothing is run on these ports

2> Open command prompt from start and type netstat -ano | findstr 8010 to check if the port are being used. if they are used then you get the TCP 0.0.0.0:8005 0.0.0.0:0 LISTENING 4 TCP [::]:8005 [::]:0 LISTENING 4

then a> kill the process using the process id (4 in my case) from the task manager

If they are not being used then you see nothing in cmd

Account answered 2/4, 2019 at 17:9 Comment(0)
C
1

For me (as I was using tomcat server on VS Code). Tomcat provides a interface called "configure tomcat", there are a options below service status like start, stop etc. The reason I think your terminal showing error is due to internally tomcat is already using that port so you can stop the port from there and start your tomcat server from your IDE terminal.

For detail description and If you OS is windows, search Services and inside you can see the option 'Apache Tomcat'

Carvel answered 8/5, 2022 at 17:38 Comment(1)
This world perhaps be better as a comment or edit of an existing answer, as the underlying solution is the same as other answers.Crore
C
1

for people using IntelliJ

Goto Run --> Edit configurations

In the configuration that exists for Tomcat server, change the Admin port

enter image description here

Crossexamine answered 3/8, 2022 at 15:23 Comment(0)
B
0

What you can do is rather then killing process you can goto tomcat directory/conf/server.xml, Here you can change shutdown port(8005) to some other port. Also change default port (8080) and other to Different one. So you can run several instance of your Tomcat on single Machine. Restart Your Server (if still issue persists) Recreate it in Eclipse.

Bearberry answered 11/7, 2014 at 9:48 Comment(0)
H
0

Change Smart Tomcat Admin port to another, e.g. 8006, because it can be already in use

Hustler answered 25/8, 2023 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.