[英]Remote Mongo Connection via Pymongo
I am connecting to a remote server's port 27017 using ssh and then accessing the mongo database on that system. 我正在使用ssh连接到远程服务器的端口27017,然后访问该系统上的mongo数据库。 I can successfully connect it via the shell script.
我可以通过shell脚本成功连接它。 However, when I write a python program and try to connect to that system, I am not able to connect.
但是,当我编写python程序并尝试连接到该系统时,我无法连接。 I use the following piece of code:
我使用以下代码:
conn = MongoClient('mongodb://username:password@hostname:27017/database')
I would want to mention that I am accessing the destination system behind a proxy. 我想提一下,我正在访问代理后面的目标系统。 However, the port 27017 is enabled for my system to connect to the destination system.
但是,端口27017已启用,我的系统可以连接到目标系统。
conn = MongoClient('mongodb://username:password@hostname:27017/database')
您的主机名是27017
但是您启用的端口是27107
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.