阿飞飞飞

学而时习之

导航

mongodb远程连接出现com.mongodb.MongoSocketOpenException: Exception opening socket的问题

com.mongodb.MongoSocketOpenException: Exception opening socket???

    远程连接MongoDB出现连接不上的情况如下:

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=192.168.142.198:27017,type=UNKNOWN,state=CONNECTING,exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}] com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.(ClusterBinding.java:75)com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource(ClusterBinding.java:71)com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68)com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:158)com.mongodb.operation.

解决方法:将配置文件mongodb.conf中,bind_id=127.0.0.1改为bind_id=0.0.0.0  再重启服务

 

posted on 2021-08-19 21:45  阿飞飞飞  阅读(5263)  评论(0编辑  收藏  举报