What do i need to do java.net.connectexception connection refused connect
kavitha kandla
Greenhorn
Joined: Jul 24, 2009
Posts: 12
posted
0
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.
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
Joined: Jul 24, 2009
Posts: 12
posted
0
Thanks for the reply.
Could you please let me know the how to run the same commands in windows.
sorry, no idea, my systems are running the 18th year virus free
This message was edited 1 time. Last update was at by Matt Cartwright
kavitha kandla
Greenhorn
Joined: Jul 24, 2009
Posts: 12
posted
0
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
[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.
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.