2

I am trying to shutdown and start my tomcat after i uploaded new war file. but i am getting Connection refused error while shutdown the tomcat instance. the error is below ,

Oct 31, 2015 2:55:44 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Oct 31, 2015 2:55:44 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:498)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:370)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:457)

Tomcat stopped

Even i killed running java id using kill -9 PID but still i am getting same error and i can not start my application.

How to fix this and shutdown my tomcat without bug ?

2
  • I think the thing is not about stopping server, but about starting server ,you should post the error message when you start the server(there should be some) . Commented Oct 31, 2015 at 7:10
  • Possible duplicate stackoverflow.com/questions/5698802/… Commented Oct 31, 2015 at 7:10

3 Answers 3

1

If its windows try below to kill the running tomcat process

C:\Users\Saravana.Saravana-PC>netstat -ano  | find ":8080"
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       1448
  TCP    127.0.0.1:8080         127.0.0.1:49543        ESTABLISHED     1448
  TCP    127.0.0.1:49543        127.0.0.1:8080         ESTABLISHED     4068
  TCP    [::]:8080              [::]:0                 LISTENING       1448
  TCP    [::1]:8080             [::1]:49542            ESTABLISHED     1448
  TCP    [::1]:49542            [::1]:8080             ESTABLISHED     4068

C:\Users\Saravana.Saravana-PC>taskkill.exe /PID 1448 /F
SUCCESS: The process with PID 1448 has been terminated.

C:\Users\Saravana.Saravana-PC>

In Linux if stopTomcat.sh is not stopping tomcat then

ps -ef | grep "tomcat"
kill -9  <PID>

kill the running instance of tomcat, killing your java application wont kill tomcat

To get the running tomcat port use sudo netstat -lnp | grep <PID>

Sign up to request clarification or add additional context in comments.

7 Comments

I am using linux so i used ps -ef | grep "tomcat" and killed the corresponded running PID and again i started tomcat and shutdown tomcat but same issue rising :(
did you check the logs? what exception are you getting?
It shows java.net.BindException: Address already in use <null>:8105
are you running any other service on port 8105? it looks like some other process is already using this port. grepsudo netstat -lnp with the port, it'll show the process using the port, kill the process and try
I checked using netstat -lnp 8105 but i dont find the 8105 is listening
|
0

I cleaned my webapps and it helped me:

cd /opt/tomcat/webapps
shopt -s extglob
rm -rf !(ROOT|balancer|webdav)

after that, I was able to deploy my application

Comments

-1

Try changing the port number from 8005 to some other port number and restart Eclipse .

sometimes it may happen that the port number is blocked by sudden termination of process

1 Comment

I am running tomcat in digitalocean server not in eclipse

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.