gpt4 book ai didi

python - AWS + MongoDB : How to connect to mongo server on AWS linux instance?

转载 作者:可可西里 更新时间:2023-11-01 10:42:14 27 4
gpt4 key购买 nike

我启动了一个 AWS linux 实例并按照说明安装并运行了 mongo here . mongo 服务正在运行并在 27017 上接受连接。但是,当我使用端口 27017 访问服务器 publik dns 时,服务器没有响应,我没有看到默认的 mongo 消息。

我正在尝试在另一个实例上运行 Python(Flask) 服务器并尝试使用私有(private) ip 连接到 mongo 服务器,但连接没有发生。我在终端上收到此错误消息:

pymongo.errors.ServerSelectionTimeoutError: xxx.xx.xx.xx:27017: [Errno 111] Connection refused

这不是在 aws 上使用 mongo db 的正确方法吗?如果这种方法可行,是什么导致连接不发生?

感谢所有意见,非常感谢!

最佳答案

您的 mongodb 可能配置为仅接受来自本地主机的连接。编辑 /etc/mongod.conf 文件以注释掉下面示例中的 bindIP 行 -

# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

关于python - AWS + MongoDB : How to connect to mongo server on AWS linux instance?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37528077/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com