wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Connection Refused Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Connection Refused Exception" Watch "Connection Refused Exception" New topic
Author

Connection Refused Exception

paddy Mahadeva Iyer
Ranch Hand

Joined: Feb 10, 2007
Posts: 63
Hi,

I am working on a application that tries to send out a message to server . but when the system tries to post to the server it gets the following exception


java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:382)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:494)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
at sun.net.www.http.HttpClient.New(HttpClient.java:304)
at sun.net.www.http.HttpClient.New(HttpClient.java:316)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:817)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:769)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:694)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:861)




I found that the excption is being triggerd from my code in a line where an attempt to get an outputstream is made with the httpurlconnection object.

Can somebody tell me what are the probable causes of such an exception?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

The most common causes are a firewall between your server and client or the server is not listening. Can you open the same URL with a browser?


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

Joined: Feb 10, 2007
Posts: 63
no i cannot!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

Can you ping the server?
 
 
subject: Connection Refused Exception
 
Similar Threads
Tomcat cant recognize "error-page" tag in web.xml
how to read files from internet
java.net.ConnectionException
Shut Down a SSL Enabled JBOSS
how to resolve java.net.ConnectException: Connection refused: connect