使用我的服务器公共IP地址访问MongoDB

时间:2017-06-22 11:43:10

标签: mongodb

我目前在我的VPS服务器上托管MongoDB,安装了ubuntu 16.04。在其上安装MongoDb是成功的。我可以使用127.0.0.1 $ mongo 127.0.0.1

从SSH访问数据库

然后我在本地mac book笔记本电脑上从https://studio3t.com下载了mongoDB客户端。我实际上想使用本地安装在我机器上的mongodb客户端访问我服务器上的mongodb。我将我的服务器IP地址和默认的mongodb端口提供给mongodb客户端,如下所示,IP:69.36.180.00端口:27017这会产生以下错误

         Connection failed.
   SERVER [69.36.180.00:27017] (Type: UNKNOWN) 
 |_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Socket error: Connection refused (Connection refused)

Details:
Timed out after 30000 ms while waiting for a server that matches      
ReadPreferenceServerSelector{readPreference=primary}. Client view of 
cluster state is {type=UNKNOWN, servers=[{address=69.36.180.00:27017,
 type=UNKNOWN, state=CONNECTING, exception= {com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by
{java.net.ConnectException: Connection refused (Connection refused)}}]

但我决定使用此$ mongo 69.36.180.00从服务器本身的SSH终端访问mongodb,它也不允许它访问,下面是终端上显示的错误

   MongoDB shell version v3.4.5
   connecting to: mongodb://127.0.0.1:27017/69.36.180.00
 2017-06-22T11:35:16.300+0000 E QUERY    [thread1] Error: Failed to 
 parse mongodb:// URL: mongodb://127.0.0.1:27017/69.36.180.00 :
 connect@src/mongo/shell/mongo.js:237:13
 @(connect):1:6
exception: connect failed

我真的读过这些错误,有些人建议我取消注释bindIP中的mongod.conf,其他人建议我允许端口上的防火墙访问,我已经做了所有这些但无济于事。

如果有人可以就如何处理这个问题分享一个想法,我将不胜感激。问候

0 个答案:

没有答案