java connection mongodb error timeout and connection failure

Exception in thread "main" com.mongodb.MongoTimeoutException: 
Timed out after 30000 ms while waiting for a server that matches
 WritableServerSelector. Client view of cluster state is {type=
UNKNOWN, servers=[{address=hadoop02:12345, type=UNKNOWN, state=
CONNECTING, exception={com.mongodb.MongoSocketOpenException: 
Exception opening socket}, caused by {java.net.SocketTimeoutException:
 connect timed out}}]

Java cannot connect to Mongodb

Solution:

Modify mongod.conf in the conf file

Add bind_ip=0.0.0.0 to  allow all access

Then you can connect Navicat to test whether it can be connected

Guess you like

Origin blog.csdn.net/Poolweet_/article/details/108584967