• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to resolve java.net.ConnectException: Connection refused: connect

 
Greenhorn
Posts: 27
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to upload a file with size (>2GB).So i am using applet with servlet to upload it.When i connect applet to servlet using URL class from Java.net which is shown below:-

URL serverUrl=new URL("http://localhost:8084/JFileUpload/TestServlet");
URLConnection connection=serverUrl.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-type","application/octet-stream");

i am getting exception when executing the line shown below:-
DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());

java.net.ConnectException: Connection refused: connect
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:520)
at java.net.Socket.connect(Socket.java:470)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
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:321)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:857)

Please help me to resolve this issue.I am using netbeans IDE6.0 & Tomcat server

[ June 10, 2008: Message edited by: elay Raja ]
[ June 10, 2008: Message edited by: elay Raja ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.

This exception usually means that there is no service listening to the port you are attempting to connect to. Can you load this URL in your web browser:
http://localhost:8084/
If you are using Tomcat, you should get a Tomcat welcome screen.
 
Greenhorn
Posts: 12
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am having a similar problem.

I have an application running on Websphere 7 Dev environment
http://appl.company.com/appl/home.action
And also on my localhost system
http://localhost/appl/home.action

I am trying to access a URL like below
http://appl.company.com/SiteContent/a.html from the above application

It works perfectly fine on my local system.

But on the development environment, on this particular line :-
String stream = (new java.net.URL(url)).openStream();
I am getting a "java.net.ConnectException: Connection refused" exception

On googling i figured, such problems are either due to one of the following
- The port is wrong (cannot be this option, as same url running perfectly from local system)
- Firewall is stopping it.

Regards,
Darshan Shroff
shroffdarshan@gmail.com
 
Darshan Shroff
Greenhorn
Posts: 12
Spring Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This was basically a firewall issue. Had to do a port opening from the app server to web server by contacting our Network team.

Regards,
Darshan Shroff
shroffdarshan@gmail.com
reply
    Bookmark Topic Watch Topic
  • New Topic