• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

What do i need to do java.net.connectexception connection refused connect

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Currently iam supporting a Java project which uses FTP Action to get the files located on a say "ABC " Server and puts it back in another "bcd" server.

it is done on a click of a button for different countries and different countries servers are located in different locations.

I came to know that this type of error comes when the server is not able to listen to the port.

Means do i need to run netstat -a on the server where the web application is deployed or do i need to use netstat -a on the remote server which iam tryinging to connect through the web application.

The problem is that it is failing only for a particular country . It ran successfully for the other countries.

Could any one suggest me what i need to do in this regard.

Thanks!!
Kavitha
 
Ranch Hand
Posts: 152
VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

could you please post the entire stack trace?

Normally, this exception would be thrown from a client
that tries to connect to an endpoint where "nobody"
is listening or a firewall is dropping the client's packets.

The giveaway is "Connection refused".

Check your client endpoint configuration (remote name/address
and port) and if you can connect to the server, run a
$ netstat -an | grep \:<port>*.*LIST
where <port> is the actual port configured on your client.

If netstat doesn't display anything, the service is down.

Hope that helps.
Matt
 
kavitha kandla
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

Could you please let me know the how to run the same commands in windows.

As client and remote are windows machines.

Thanks!!
Kavitha
 
Matt Cartwright
Ranch Hand
Posts: 152
VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, no idea, my systems are running the 18th year virus free
 
kavitha kandla
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here with enclosing the stack trace.

at com.lilly.sir.load.FTPJakartaHelper.connect(FTPJakartaHelper.java:47)
at com.lilly.sir.load.action.FTPAction.launch(FTPAction.java:124)
at com.lilly.sir.load.JobStep.launch(JobStep.java:320)
... 6 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:464)
at java.net.Socket.connect(Socket.java:414)
at java.net.Socket.<init>(Socket.java:310)
at java.net.Socket.<init>(Socket.java:125)
at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:52)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:161)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:249)
at com.lilly.sir.load.FTPJakartaHelper.connect(FTPJakartaHelper.java:36)
com.lilly.sir.load.JobStepException: Error connecting to FTP server in FTPJakartaHelper.connect
Command Log:

at com.lilly.sir.load.FTPJakartaHelper.connect(FTPJakartaHelper.java:47)
at com.lilly.sir.load.action.FTPAction.launch(FTPAction.java:124)
at com.lilly.sir.load.JobStep.launch(JobStep.java:320)
at com.lilly.sir.load.Job.genericStepsProcess(Job.java:298)
at com.lilly.sir.load.Job.processPreLoad(Job.java:328)
at com.lilly.sir.load.Job.processLoad(Job.java:346)
at com.lilly.sir.load.Scheduler.startLoad(Scheduler.java:295)
at com.lilly.sir.load.launcher.SchedulerLauncherThread.run(SchedulerLauncherThread.java:142)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:464)
at java.net.Socket.connect(Socket.java:414)
at java.net.Socket.<init>(Socket.java:310)
at java.net.Socket.<init>(Socket.java:125)
at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:52)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:161)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:249)
at com.lilly.sir.load.FTPJakartaHelper.connect(FTPJakartaHelper.java:36)
... 8 more

java.net.ConnectException: Connection refused java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:464)
at java.net.Socket.connect(Socket.java:414)
at java.net.Socket.<init>(Socket.java:310)
at java.net.Socket.<init>(Socket.java:125)
at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:52)
at org.apache.commons.net.SocketClient.connect


Any help will be gratefull enough :)
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[quote=kavitha kandla]Caused by: java.net.ConnectException: Connection refused
...
Caused by: java.net.ConnectException: Connection refused
...
java.net.ConnectException: Connection refused java.net.ConnectException: Connection refused[/quote]
You're connections are being blocked. Can you connect using telnet? Open a command window, type in "telnet <port number>" and see what happens. If that also disallows your connections then the problem is not in Java.
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the telnet is to a different host, you'll want to provide the host name as well, as in:
The error you're getting means either there is nothing listening on that host/port, or (as mentioned) it is being blocked.

There are a number of different reasons for this. Are you sure the service is running? Are you sure it is listening on the correct interface? Is it blocked by a firewall/router either on the client or server end?

Your network administrator should be able to help you get to the bottom of this.
 
Rob Spoor
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark E Hansen wrote:If the telnet is to a different host, you'll want to provide the host name as well, as in:


Uh yeah, that's what I meant...
 
kavitha kandla
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


SOrry don't have telnet but have putty and ssh.

the code is deployed on unix server say "abcd".

Now how to find out whether the connection refused is coming from the ftp code or ftp user used for connecting the server.

Infact i tried logging into the target windows server using an FTP from another windows server and iam able to log in.

Suggestions required.
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic