Mongodb: failed to connect to server on first connect

前端 未结 13 2975
陌清茗
陌清茗 2020-12-15 15:52

I get the following error:

Warning { MongoError: failed to connect to server [mongodb:27017] on first connect
    at Pool. (/Users/michaelks         


        
13条回答
  •  春和景丽
    2020-12-15 16:14

    if it is cluster MongoDB then you need to add your current IP to the cluster, to add your current IP address you need to complete few steps below-

    step 1- go to login page of Mongodb and login with valid credential - https://cloud.mongodb.com/user#/atlas/login
    step 2- CLick Network Access from left sidebar under Security Section
    Step 3 - Click Add IP Address
    Step 4 - Click Add Current IP Address or Allow Connection From Any Where
    now try to connect - npm start
    

    and for Local MongoDB use mongo String like "mongodb+srv://username:pass%40ord@clastername-blqnk.mongodb.net/test?retryWrites=true&w=majority"

    password must be encoded like example string

提交回复
热议问题