在代理后面使用mongoose连接到MongoDB数据库 [英] Connect to MongoDB database using mongoose behind a proxy
问题描述
我正在使用mongoose在server.js文件中连接到mongolab中的数据库:
I am using mongoose to connect to my database in mongolab in my server.js file :
mongoose.connect('mongodb://MyUsername:MyPassword@ds089702.mongolab.com:89702/todo');
当我使用node server.js
命令启动服务器时,我在终端中看到此错误
When i launch my server with node server.js
command, i see this error in my terminal
无法连接到[ds089702.mongolab.com:89702]
failed to connect to [ds089702.mongolab.com:89702]
我非常确定这只是一个企业代理问题,所以我想知道如何使用猫鼬通过企业代理连接到我的数据库?
I am very sure that is just a corporate proxy problem, so I'm wondering how can I connect to my database over the corporate proxy using mongoose ?
谢谢!
推荐答案
我遇到了同样的问题,并找到了对我有用的解决方案.
I had the same problem and figured out a solution that worked for me.
mongodb URI示例:
Example mongodb URI:
mongodb://:@ ds123456.mlab.com:37409/dbName
mongodb://:@ds123456.mlab.com:37409/dbName
- 使用代理客户端(例如 Proxifier ).
- 使用公司代理作为地址通过端口8080创建HTTPS代理.
- 使用URI的端口作为目标端口为mlab创建一条规则,该规则将使用您在上面创建的HTTPS代理作为其操作.
- 在规则列表中将您的mlab规则置于高优先级.
这篇关于在代理后面使用mongoose连接到MongoDB数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!