File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Catalina.stop: java.net.ConnectException: Connection refused: connect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Catalina.stop: java.net.ConnectException: Connection refused: connect" Watch "Catalina.stop: java.net.ConnectException: Connection refused: connect" New topic
Author

Catalina.stop: java.net.ConnectException: Connection refused: connect

Joseph Bashir
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
Hi

I am facing problem with Tomcat5.0. Tomcat is running but it does not open the url http://192.168.1.21:8080/. This is what I get in the log file:

Catalina.stop: java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:410)
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.stopServer(Bootstrap.java:336)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:427)

Please help. Thanks.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Check if there is already an another application running on port 8080 if so change your tomcat port or shutdown that another application.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Jay Rose
Greenhorn

Joined: Aug 21, 2007
Posts: 2
you ever happen to figure this out?

have the same problem. 10.4 server, ran a security update. now tomcat won't start, and when i run stop i get that "Catalina.stop: java.net.ConnectException: Connection refused". nothing else was changed/added, and nothing else seems to be running on 8080.

what a bummer. any ideas would be huge.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Jay, did you check if you have some other program running that already allocates port 8080? You can use a program like CurrPorts to see which programs have which TCP/IP ports allocated (on Windows).
[ August 22, 2007: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jay Rose
Greenhorn

Joined: Aug 21, 2007
Posts: 2
thanks jesper. no, it's not that. downloaded something called 'whatport' sounds similar. nothing running on 8080.

very frustrating. the security update did talk about "fixing holes" in tomcat. didn't realize that meant putting up the great wall of china.
LF Intalan
Greenhorn

Joined: Mar 20, 2006
Posts: 3
Hi Guys, I'm also having the same problems with this. Any idea on how to fix this exception? Mine's like this:

org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused: connect
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
Jo�o Noronha
Greenhorn

Joined: May 23, 2008
Posts: 2
Hi guys, same problem here.
The port used (8082) is not busy with other app,
startup is ok, I have to use Ctrl+C to shutdown.
Shutdown.bat file does nothing 1st time, afterwards gives connect error.
How did you solve it?
Tx,
JN
karthikeyan Chockalingam
Ranch Hand

Joined: Sep 06, 2003
Posts: 259
In Windows, if Tomcat was installed using apache-tomcat-6.0.16.exe [or a previous exe installer], during installation we should not check[select] the option service [ or something similar to NT service [NT/2k/XP only]].

If we had selected the option we may get
"Catalina.stop: java.net.ConnectException: Connection refused: connect".


But I also find other reasons [in other OS] like,
http://esupport.marvinsweb.net/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=137
[ May 25, 2008: Message edited by: karthi keyan ]

http://www.skillassert.com


Jo�o Noronha
Greenhorn

Joined: May 23, 2008
Posts: 2
No, the service was already manual, but even after I removed it from a service, same happens.
This is happening with Tomcat 5.0.30, Tomcat 5.5, and Tomcat 6.0.
Using JDK1.5.0_12 or JDK1.6.0_04 is also the same.
I checked the AJP ports (8009 and 8443) and they are free until Tomcat is started.

Another weird behaviour, and this might be a clue:
I have problems with HTTP request and reponses, they start freezing
after a while, either just after 1st request of JWS app or after 5 page refresh on simple Tomcat documentation page. The images start to not appear.
This is similar behaviour to reported in this bug:
https://issues.apache.org/bugzilla/show_bug.cgi?id=35497
There is no answer, so I'll post it to the Tomcat user mailing list.

Regards,
JN

[ May 26, 2008: Message edited by: Jo�o Noronha ]

[ May 26, 2008: Message edited by: Jo�o Noronha ]
[ May 28, 2008: Message edited by: Jo�o Noronha ]
Bob Grossman
Ranch Hand

Joined: Dec 18, 2008
Posts: 69
I am having a very similar problem. Complete disclosure: I am a rank amateur, but my collaborator is incommunicado for the next week. We have Tomcat 5 on a Linux server running similar Web applications on two different ports. One, at the default port, is working fine. The other, at 9183, is not accessible through a Web browser. When I log in as root and try to start the uncommunicative Tomcat up, nothing appears to happen, but when I try to shut it down, I get,



Looking in various Internet posts about this error, I saw a suggestion to use netstat to see whether the port was already busy. Here is what I got:



The 128.163.162.45 is my own machine; I'm using it to SSH into the server machine. However, when I completely disconnect my machine from the server and instead SSH in from a different machine, the two connections remain, and I see two others from crawl-66-249-70-2.

From what I can understand on the Web, it's normal to have a few CLOSE_WAIT connections to a port. But they should disappear when I log out, right? So should I kill them? If so, how do I do that?
[ December 18, 2008: Message edited by: Bob Grossman ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Welcome to the JavaRanch.
I would expect to get a "java.net.ConnectException: Connection refused" error from the shutdown script if Tomcat were not up and running. Since you can't connect with a browser, that deepens my suspicion.
Try running "netstat -ap | grep 9183". That will tell you what PID is listening on that port. You can use "ps" to find out the executable. I'll bet it's not tomcat...


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Bob Grossman
Ranch Hand

Joined: Dec 18, 2008
Posts: 69
Thanks for your reply. I logged in as root and entered "netstat -ap | grep 9183", and no output was returned.



Yesterday, after posting my query, I fiddled around a bit and discovered that the CLOSE_WAIT connections in my previous post were created when I tried to use my browser to connect to 9183. I killed them manually, but it didn't solve my fundamental problem, which is that Tomcat is either not listening or not responding to browsers at that port.
Bob Grossman
Ranch Hand

Joined: Dec 18, 2008
Posts: 69
Here's more information. If I run the startup script for the misbehaving Tomcat, then I run top, I see a ridiculously CPU-heavy Java process appear, like 95-98% CPU, and it does not go away over time. On the other hand, if I stop our well-behaving Tomcat instance and then restart it, a similarly large Java process appears, but it quickly goes away.

So it looks to me like the Tomcat startup process is hanging or entering an infinite loop. The whole port thing seems to be a red herring.

Here's the catalina.out log from a successful startup back in November:



and here it is from today:



No, the Context configuration file hasn't changed between then and now. I guess it's possible it's hanging up somewhere later in the process, before the last few successful executions have been written to the log.
[ December 19, 2008: Message edited by: Bob Grossman ]
Bob Grossman
Ranch Hand

Joined: Dec 18, 2008
Posts: 69
Over the weekend I was able to figure out what was going wrong.

The Catalina.stop message was a complete red herring. The problem was that Tomcat was entering an infinite loop when it started up. The infinite loop was inside a method called by a method called by a method called by a servlet method that was called only upon Tomcat startup.

Isolating the method that was causing the infinite loop was time-consuming, because Tomcat wrote to the log only up to the point that it called the servlet method; everything that happened once it entered the servlet method was invisible. So I needed to comment out various code, start up Tomcat, and use top to see if it entered the infinite loop (that 95% Java process I mentioned earlier). If it did, I used kill -9 to kill the Java process so I could comment out more code and restart again.

The infinite loop was caused by one misplaced variable. Unfortunately, nothing much was happening inside the loop, so it just kept going around and around without overflowing any buffer. Allowing this process to go unchecked seems like a flaw in Tomcat design to me.

Anyway, thanks to you who offered some help with this problem.
 
jQuery in Action, 2nd edition
 
subject: Catalina.stop: java.net.ConnectException: Connection refused: connect
 
Similar Threads
tomcat configuration problem
Another shutting down problem
"Publishing Failed" error with Tomcat v5.5
Tomcat 5.5 will not start
JMX Conenctor setting in WAS 6.0