MongoError: auth failed mongoose connection string

前端 未结 11 1638
一向
一向 2020-12-29 07:10

I can connect to the DB through terminal, but getting this error using mongoose and gulp. mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:246 MongoError: auth

11条回答
  •  粉色の甜心
    2020-12-29 07:47

    just add ?authSource=yourDB&w=1 to end of db url

     mongoose.connect('mongodb://user:password@host/yourDB?authSource=yourDB&w=1')
    

    this work for me . &w=1 is important

提交回复
热议问题