mongoDB连接尝试失败:socketException:连接到server_ip的错误:27017

发布于 2025-02-13 01:04:44 字数 952 浏览 0 评论 0原文

我买了一个VPS,我想将MongoDB服务器放在那里。我使用SSH隧道连接到VPS,安装MongoDB并开始。问题是,如何将VPS服务器添加到MongoDB指南针? 我试图将其与指南针连接,但它不断向我展示连接eHostunreach my_vps_ip:27017

我试图通过我的本地终端与此命令连接:

mongo --host my_vps_ip  

但是它给我带来了这个错误:

MongoDB shell version v4.2.19
connecting to: mongodb://my_vps_ip:27017/?compressors=disabled&gssapiServiceName=mongodb
2022-07-04T15:13:34.970-0500 E  QUERY    [js] Error: couldn't connect to server my_vps_ip:27017, connection attempt failed: SocketException: Error connecting to my_vps_ip:27017 :: caused by :: No route to host :
connect@src/mongo/shell/mongo.js:353:17
@(connect):2:6
2022-07-04T15:13:34.977-0500 F  -        [main] exception: connect failed
2022-07-04T15:13:34.977-0500 E  -        [main] exiting with code 1

这是我的配置文件代码:

net:
port:27017
bindIp my_vps_ip,127.0.0.1

可以连接到我的VPS MongoDB通过指南针?

抱歉,如果是la脚的问题,只是第一次使用VP,对我来说很复杂。

I bought a VPS and I want to put MongoDB server there. I connect to VPS with ssh tunnel, install MongoDB and start it. The question is, that how can I add VPS server to MongoDB Compass?
i tried to connect it with compass but it keep showing me connect EHOSTUNREACH my_vps_ip:27017

I was trying to connect via my local terminal with this command :

mongo --host my_vps_ip  

but it throws me this error :

MongoDB shell version v4.2.19
connecting to: mongodb://my_vps_ip:27017/?compressors=disabled&gssapiServiceName=mongodb
2022-07-04T15:13:34.970-0500 E  QUERY    [js] Error: couldn't connect to server my_vps_ip:27017, connection attempt failed: SocketException: Error connecting to my_vps_ip:27017 :: caused by :: No route to host :
connect@src/mongo/shell/mongo.js:353:17
@(connect):2:6
2022-07-04T15:13:34.977-0500 F  -        [main] exception: connect failed
2022-07-04T15:13:34.977-0500 E  -        [main] exiting with code 1

here is my config file code :

net:
port:27017
bindIp my_vps_ip,127.0.0.1

it is possible to connect to my vps mongodb via compass ?

Sorry if it's lame questions, just first time using VPS and it's pretty complex to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文