com.mongodb.MongoException$Network: can't call something : /127.0.0.1:27017/imdb

JIRA | Douglas Hubler | 5 years ago
  1. 0

    WAIT! Before you close this as a duplicate, I do not believe anyone has given the full details. The problem is you simply cannot connect to a mongod from java when it is bound to the 127.0.0.1 interface only. Step 1: configure mongod to 127.0.0.1 only -------------------------- logpath=/var/log/mongo/mongod.log logappend=true fork = true dbpath=/var/lib/mongo replSet =sipxecs port=27017 bind_ip=127.0.0.1 ------------------------- Step 2: Compile and run this code ----------------------------- import com.mongodb.MongoURI; import com.mongodb.Mongo; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.BasicDBObject; public class Test { public static void main(String[] args) throws Exception { Mongo m = new Mongo("127.0.0.1", 27017); DB d = m.getDB("imdb"); DBCollection col = d.getCollection("imdb"); BasicDBObject o = new BasicDBObject(); col.findOne(o); } } -------------------------- You will get the following error ---------------------------- Jan 25, 2012 4:44:21 PM com.mongodb.DBTCPConnector fetchMaxBsonObjectSize WARNING: Exception determining maxBSON size using0 java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:228) at com.mongodb.DBPort.go(DBPort.java:112) at com.mongodb.DBPort.go(DBPort.java:93) at com.mongodb.DBPort.findOne(DBPort.java:146) at com.mongodb.DBPort.runCommand(DBPort.java:157) at com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:457) at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:444) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305) at com.mongodb.DBCollection.findOne(DBCollection.java:647) at com.mongodb.DBCollection.findOne(DBCollection.java:626) at Test.main(Test.java:14) Jan 25, 2012 4:44:21 PM com.mongodb.DBPortPool gotError WARNING: emptying DBPortPool to 127.0.0.1:27017 b/c of error java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:228) at com.mongodb.DBPort.go(DBPort.java:112) at com.mongodb.DBPort.call(DBPort.java:79) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:218) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305) at com.mongodb.DBCollection.findOne(DBCollection.java:647) at com.mongodb.DBCollection.findOne(DBCollection.java:626) at Test.main(Test.java:14) Exception in thread "main" com.mongodb.MongoException$Network: can't call something : /127.0.0.1:27017/imdb at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:227) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305) at com.mongodb.DBCollection.findOne(DBCollection.java:647) at com.mongodb.DBCollection.findOne(DBCollection.java:626) at Test.main(Test.java:14) Caused by: java.io.IOException: couldn't connect to [/127.0.0.1:27017] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:228) at com.mongodb.DBPort.go(DBPort.java:112) at com.mongodb.DBPort.call(DBPort.java:79) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:218)

    JIRA | 5 years ago | Douglas Hubler
    com.mongodb.MongoException$Network: can't call something : /127.0.0.1:27017/imdb
  2. 0

    Error on starting play framework application in cloudfoundry

    Stack Overflow | 4 years ago | Hariharan
    com.mongodb.MongoException$Network: can't call something
  3. 0

    GitHub comment 3#5978489

    GitHub | 5 years ago | michaelmosmann
    com.mongodb.MongoException$Network: can't call something : mub001/0:0:0:0:0:0:0:1:12345/test
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [mongodb-user] Strange behavior in testing 2.6.0.rc0 - Grokbase

    grokbase.com | 4 months ago
    com.mongodb.MongoException$Network: Read operation to server localhost/127.0.0.1:27017 failed on database sbtest
  6. 0

    We've 3 nodes - 1 master and 2 slaves. We are using replica set. The query code set SLAVE_OK. 2011-04-14 01:13:21,850 ERROR [Refinance-Base-22-1] com.leadpoint.syndication.db.mongo.mortgage.SrpTableQueryEngine - SrpTableQueryEngine: exception com.mongodb.MongoException$Network: can't call something com.mongodb.MongoException$Network: can't call something at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:220) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:284) at com.mongodb.DB.command(DB.java:152) at com.mongodb.DB.command(DB.java:141) at com.mongodb.DB.getLastError(DB.java:302) at com.leadpoint.syndication.db.mongo.mortgage.SrpTableQueryEngine.fetch(SrpTableQueryEngine.java:69) at com.leadpoint.syndication.db.mongo.mortgage.SrpTableQueryEngine.execute(SrpTableQueryEngine.java:115) at com.leadpoint.syndication.db.mongo.refinance.RefinanceQueryEngine$1.run(RefinanceQueryEngine.java:428) at java.lang.Thread.run(Thread.java:619) Caused by: java.io.IOException: couldn't connect to [mongo-prod-mem1.lps.la2.estalea.net/10.2.5.37:4110] bc:java.net.ConnectException: Connection timed out at com.mongodb.DBPort._open(DBPort.java:205) at com.mongodb.DBPort.go(DBPort.java:85) at com.mongodb.DBPort.go(DBPort.java:66) at com.mongodb.DBPort.call(DBPort.java:56) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:211) bash-3.2$ /usr/local/mongodb-linux-x86_64-1.6.3/bin/mongo mongo-prod-mem1.lps.la2.estalea.net:4110 MongoDB shell version: 1.6.3 connecting to: mongo-prod-mem1.lps.la2.estalea.net:4110/test > show dbs admin local lp

    JIRA | 6 years ago | Joseph Wang
    com.mongodb.MongoException$Network: can't call something

    1 unregistered visitors
    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

      at com.mongodb.DBPort._open()
    2. MongoDB Java Driver
      DBTCPConnector.call
      1. com.mongodb.DBPort._open(DBPort.java:228)
      2. com.mongodb.DBPort.go(DBPort.java:112)
      3. com.mongodb.DBPort.call(DBPort.java:79)
      4. com.mongodb.DBTCPConnector.call(DBTCPConnector.java:218)
      4 frames