Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-249

Java Driver cannot connect to 'localhost' when mongod is listening only on 127.0.0.1 (or "localhost")

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.4
    • Fix Version/s: 2.8.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Reproducible on Mac
    • Backwards Compatibility:
      Fully Compatible
    • # Replies:
      12
    • Last comment by Customer:
      false

      Description

      Issue reported by user but reproducible by me.

      When working with the 2.4 Java driver on Mac OS X (10.6.x) , where mongod listens on bind_ip 127.0.0.1 (also tried with 'localhost'), an empty Mongo constructor [Mongo()] connects. However, connecting to a hostname of "localhost" fails with:

      com.mongodb.MongoInternalException: DBPort.findOne failed
      at com.mongodb.DBPort.findOne(DBPort.java:153)
      at com.mongodb.DBPort.runCommand(DBPort.java:159)
      at com.mongodb.DBTCPConnector.testMaster(DBTCPConnector.java:371)
      at com.mongodb.Mongo.<init>(Mongo.java:167)
      at com.mongodb.Mongo.<init>(Mongo.java:151)
      at com.mongodb.Mongo.<init>(Mongo.java:119)

      Adding an explicit port number makes no difference.'

      User reports they see same behavior if they specify a hostname of "127.0.0.1" although on my machine with a homebrew sourced 1.6.3 and 1.6.5 it functions with "127.0.0.1". If I remove the bind_ip declaration it works fine.

      User reports behavior did not occur with the 2.1 Java driver — I've confirmed this. Uncertain if it happens on other platforms yet.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  5 years, 22 weeks, 4 days ago
                  Date of 1st Reply: