Connect to MongoDB database using mongoose behind a proxy

泄露秘密 提交于 2019-12-19 02:09:24

问题


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'); 

When i launch my server with node server.js command, i see this error in my terminal

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 ?

Thank you!


回答1:


I had the same problem and figured out a solution that worked for me.

Example mongodb URI:

mongodb://:@ds123456.mlab.com:37409/dbName

  1. Use a proxy client (e.g. Proxifier).
  2. Create a HTTPS proxy through port 8080 using your corporate proxy as the address.

  1. Create a rule for mlab using your URI's port as the target port, which uses the HTTPS proxy you created above as its action.

  1. Prioritize your mlab rule high in the rules list.



来源:https://stackoverflow.com/questions/33483140/connect-to-mongodb-database-using-mongoose-behind-a-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!