java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect

JIRA | Alan Williamson | 4 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    The Java driver is great when everything goes right. However, the weakness can be seen when things start to go wrong. Let me illustrate with an example. A very simple one ... detecting when the server is available. You can't! Say for example you wanted to make sure the server was available (maybe you start your client before the server, or the server goes away for maintenance for a few moments (backup)). Take the following piece of code: try{ mongo.getConnector().requestEnsureConnection(); }catch(Exception e){ // never thrown } Why is the following exception (see below) masked? It is logged out to the JUL but that is of no use to the calling application. The mongo.getConnector().isOpen() also suffers the same fate. Why on earth are these exceptions masked? This is Java 101. WARNING: Exception executing isMaster command on /127.0.0.1:27017 java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect at com.mongodb.DBPort._open(DBPort.java:214) at com.mongodb.DBPort.go(DBPort.java:107) at com.mongodb.DBPort.go(DBPort.java:88) at com.mongodb.DBPort.findOne(DBPort.java:143) at com.mongodb.DBPort.runCommand(DBPort.java:148) at com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548) at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:527) at com.mongodb.DBTCPConnector.requestEnsureConnection(DBTCPConnector.java:129) at com.profiler.ProfilerExtension.run(ProfilerExtension.java:126) at java.lang.Thread.run(Thread.java:619) So the question is, how does one handle the fact a server has gone away? What is the magic here to determine what is what?

    JIRA | 4 years ago | Alan Williamson
    java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect
  2. 0

    ADB Connection Error

    Stack Overflow | 4 years ago | Raveesh Lawrance
    java.io.IOException: An existing connection was forcibly closed by the remote host at sun.nio.ch.SocketDispatcher.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(Unknown Source) at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) at sun.nio.ch.IOUtil.read(Unknown Source) at sun.nio.ch.SocketChannelImpl.read(Unknown Source) at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:395) at com.android.ddmlib.Device.executeShellCommand(Device.java:462) at com.android.ddmuilib.logcat.LogCatReceiver$1.run(LogCatReceiver.java:110)
  3. 0

    java.lang.IllegalArgumentException: URI scheme is not "file"

    java-forums.org | 8 months ago
    java.io.IOException: Server returned HTTP response code: 403 for URL: at sun.net. at slideshowapplet.SlideshowApplet.doListofImagefiles (SlideshowApplet.java:461) at slideshowapplet.SlideshowApplet.init(SlideshowAppl et.java:180) at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Plugin2Manager.java:1658)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    java.lang.IllegalArgumentException: URI scheme is not "file"

    java-forums.org | 8 months ago
    java.io.IOException: Server returned HTTP response code: 403 for URL: at sun.net. at slideshowapplet.SlideshowApplet.doListofImagefiles (SlideshowApplet.java:484) at slideshowapplet.SlideshowApplet.init(SlideshowAppl et.java:182) at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Plugin2Manager.java:1658)
  6. 0

    data nodes evicted randomly and cluster marks node... - Cloudera Community

    cloudera.com | 1 year ago
    java.io.IOException: Broken pipe         at sun.nio.ch.FileDispatcherImpl.write0(Native Method)         at sun.nio.ch.SocketDispatcher.write(SocketDispatcher .java:47)         at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.jav a:93)         at sun.nio.ch.IOUtil.write(IOUtil.java:65)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.IOException

      couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused: connect

      at com.mongodb.DBPort._open()
    2. MongoDB Java Driver
      DBTCPConnector.requestEnsureConnection
      1. com.mongodb.DBPort._open(DBPort.java:214)
      2. com.mongodb.DBPort.go(DBPort.java:107)
      3. com.mongodb.DBPort.go(DBPort.java:88)
      4. com.mongodb.DBPort.findOne(DBPort.java:143)
      5. com.mongodb.DBPort.runCommand(DBPort.java:148)
      6. com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548)
      7. com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:527)
      8. com.mongodb.DBTCPConnector.requestEnsureConnection(DBTCPConnector.java:129)
      8 frames
    3. com.profiler
      ProfilerExtension.run
      1. com.profiler.ProfilerExtension.run(ProfilerExtension.java:126)
      1 frame
    4. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:619)
      1 frame