Remote connection failed with MongoDB HELP

0

The truth is that I am a novice in programming and I have a task that is giving me a headache.

It is to create a database in MongoDB that synchronizes with the data with an application in Java in NetBeans . I get it, insert the data and it appears in my database. The problem is when I connect remotely to other computers, my friends get this error.

  

com.mongodb.DBTCPConnector initDirectConnection WARNING: Exception   executing isMaster command on Jorge-Luis-Julian-Sanchez / (my IP) 27017   java.io.IOException: could not connect to   [Jorge-Luis-Julian-Sanchez / (MY IP): 27017]   bc: java.net.SocketTimeoutException: connect timed out 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:544)     at com.mongodb.Mongo.getMaxBsonObjectSize (Mongo.java:600) at   com.mongodb.DBApiLayer $ MyCollection.insert (DBApiLayer.java:233) at   com.mongodb.DBApiLayer $ MyCollection.insert (DBApiLayer.java:205) at   com.mongodb.DBCollection.insert (DBCollection.java:57) at   com.mongodb.DBCollection.insert (DBCollection.java:100) at   testmongo.InsertSQL.main (InsertSQL.java:44)

What can I do?

    
asked by Jorge Julian 17.05.2018 в 11:30
source

2 answers

0

The problem is that you are running the database locally, usually mongoDB runs on localhost: 27017. To be synchronized in other machines you have to place your database on a web server for example, another option is that locally each machine that will use the program also runs mongoDB

    
answered by 17.05.2018 в 18:18
0

By default, MongoDB does not allow remote connections. You will have to enable access in the mongod.conf file by adding:

  

bind_ip = 127.0.0.1, TU_IP_PRIVADA

Since both are on the same LAN, you only need to link MongoDB to your own private IP interface.

More information

    
answered by 18.05.2018 в 14:38