java.net.ConnectException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

To restart the Selenium Webdriver mock browser in a testcase, first use 'driver.close()' and then reinstantiate the driver.

tip

Firewall might be blocking your connection, or MySQL it's not running on your server machine.


rafael
tip

Check if you have started your server, or if your server is set to listen to the port you're trying to connect and is waiting to accept connections and check if the firewall isn't blocking your connection.


rafael
tip

spring-data-redis requires redis 2.6+ to work properly.

tip

Check if your MongoDB is available.


rp
tip

host port isnt set

tip

Check if ip adress is correct, if the port is correct, and if the server is up and running and waiting for connections. Also, check if there's no firewall blocking you and if your internet connection is working.


rafael

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • *Steps to reproduce* # Create a job with a task of type SSH that could run SSH commands on a remote server. # Choose the authentication type to either *Key without passphrase* OR *key with passphrase* # Enter a command such as "mkdir /home/smaiyaki/hello" # Run the build and it will fail with the following error in the build logs. {noformat} Failed to connect to host net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods at net.schmizz.sshj.userauth.UserAuthImpl.authenticate(UserAuthImpl.java:114) at net.schmizz.sshj.SSHClient.auth(SSHClient.java:205) at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:305) at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:82) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:187) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:93) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:87) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:206) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:103) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:111) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52) at java.lang.Thread.run(Thread.java:722) Caused by: net.schmizz.sshj.userauth.UserAuthException: publickey auth failed at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:157) at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:474) at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:127) at net.schmizz.sshj.transport.Decoder.received(Decoder.java:195) at net.schmizz.sshj.transport.Reader.run(Reader.java:72) {noformat} The following appears in the server logs: {noformat} 2013-01-30 22:11:45,417 INFO [qtp35496097-123] [AccessLogFilter] sultan GET http://localhost:1044/bamboo44/ajax/viewPlanUpdates.action?sinceSystemTime=0&lastProject= 158047kb 2013-01-30 22:11:45,532 DEBUG [qtp35496097-123] [AccessLogFilter] END: sultan GET http://localhost:1044/bamboo44/ajax/viewPlanUpdates.action?sinceSystemTime=0&lastProject= 158047kb-68706kb 115ms 2013-01-30 22:11:50,056 ERROR [7-BAM::Default Agent::Agent:pool-16-thread-1] [Promise] <<authenticated>> woke to: net.schmizz.sshj.userauth.UserAuthException: publickey auth failed 2013-01-30 22:11:50,056 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [UserAuthImpl] `publickey` auth failed 2013-01-30 22:11:50,062 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [ExecuteBuildTask] TESTA-SCP-JOB1-12: Running post build plugin 'NCover Results Collector' 2013-01-30 22:11:50,092 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [NCoverBuildProcessor] inside NCoverBuildProcessor.call() {noformat} This issue is replicable even with the default SSH port of 22. Changing the authentication type to password works fine. *Edits* The password authentication also fails if the SSH port is not the default 22 with the error message below thrown in the build logs: {noformat} Failed to connect to host java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:70) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:77) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:103) at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:74) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:187) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:93) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:87) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:206) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:103) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:111) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52) at java.lang.Thread.run(Thread.java:722) {noformat}
    via by Sultan Maiyaki [Atlassian],
  • *Steps to reproduce* # Create a job with a task of type SSH that could run SSH commands on a remote server. # Choose the authentication type to either *Key without passphrase* OR *key with passphrase* # Enter a command such as "mkdir /home/smaiyaki/hello" # Run the build and it will fail with the following error in the build logs. {noformat} Failed to connect to host net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods at net.schmizz.sshj.userauth.UserAuthImpl.authenticate(UserAuthImpl.java:114) at net.schmizz.sshj.SSHClient.auth(SSHClient.java:205) at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:305) at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:82) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:187) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:93) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:87) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:206) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:103) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:111) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52) at java.lang.Thread.run(Thread.java:722) Caused by: net.schmizz.sshj.userauth.UserAuthException: publickey auth failed at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:157) at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:474) at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:127) at net.schmizz.sshj.transport.Decoder.received(Decoder.java:195) at net.schmizz.sshj.transport.Reader.run(Reader.java:72) {noformat} The following appears in the server logs: {noformat} 2013-01-30 22:11:45,417 INFO [qtp35496097-123] [AccessLogFilter] sultan GET http://localhost:1044/bamboo44/ajax/viewPlanUpdates.action?sinceSystemTime=0&lastProject= 158047kb 2013-01-30 22:11:45,532 DEBUG [qtp35496097-123] [AccessLogFilter] END: sultan GET http://localhost:1044/bamboo44/ajax/viewPlanUpdates.action?sinceSystemTime=0&lastProject= 158047kb-68706kb 115ms 2013-01-30 22:11:50,056 ERROR [7-BAM::Default Agent::Agent:pool-16-thread-1] [Promise] <<authenticated>> woke to: net.schmizz.sshj.userauth.UserAuthException: publickey auth failed 2013-01-30 22:11:50,056 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [UserAuthImpl] `publickey` auth failed 2013-01-30 22:11:50,062 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [ExecuteBuildTask] TESTA-SCP-JOB1-12: Running post build plugin 'NCover Results Collector' 2013-01-30 22:11:50,092 INFO [7-BAM::Default Agent::Agent:pool-16-thread-1] [NCoverBuildProcessor] inside NCoverBuildProcessor.call() {noformat} This issue is replicable even with the default SSH port of 22. Changing the authentication type to password works fine. *Edits* The password authentication also fails if the SSH port is not the default 22 with the error message below thrown in the build logs: {noformat} Failed to connect to host java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:70) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:77) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:103) at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:74) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:187) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:93) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:87) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:206) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:103) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:111) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52) at java.lang.Thread.run(Thread.java:722) {noformat}
    via by Sultan Maiyaki [Atlassian],
  • sending an email from java
    via Stack Overflow by Ashwin
    ,
    • java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391) at java.net.Socket.connect(Socket.java:579) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:70) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:77) at net.schmizz.sshj.SocketClient.connect(SocketClient.java:103) at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:74) at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:187) at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:93) at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:87) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:206) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:103) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:111) at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$2.run(NamedThreadFactory.java:52) at java.lang.Thread.run(Thread.java:722)

    Users with the same issue

    Unknown visitor1 times, last one,
    jf-ast
    3 times, last one,
    Axelo
    2 times, last one,
    Andreas Häber
    2 times, last one,
    Unknown User
    1 times, last one,
    977 more bugmates