MongooseError [MongooseServerSelectionError]: connection to 52.6.250.237:27017 closed

后端 未结 5 1249
盖世英雄少女心
盖世英雄少女心 2021-01-01 12:43

i am trying to save data in mongodb through post method and using mongodb atala with node.js but it keeps giving me an error, i provided correct connection string and correc

相关标签:
5条回答
  • 2021-01-01 13:24

    You Can Solve This Problem By Going into Your Network Access Panel

    Then Click Add IP Address

    & Then Fill 0.0.0.0/0 Then Click Confirm

    Don't Do this in Production But in Development, it will Work

    0 讨论(0)
  • 2021-01-01 13:24

    I had the same issue but I success to fix it. On your MongoDB account, check the IP you choose to connect your application.

    If you start working on a initial IP and try to work using another IP address it won't work.

    In mongoDB:

    NetworkAccess/ (verify the IP you registered is the same than this your actually used). You can select : Add IP address

    0 讨论(0)
  • 2021-01-01 13:32

    This is probably because the IP of your machine changes, it should not happen in production, but to fix it you need to go to the network access pannel -> Add IP Address and click on "Add this IP address" and I´s going to work, until it changes again.

    0 讨论(0)
  • 2021-01-01 13:38

    Did you have this line in your index.js app.use(cors())?

    Try to delete this line and delete everything that involves cors.

    If this don't work try the Mehdi Berra's solution

    0 讨论(0)
  • 2021-01-01 13:46

    I had this similar problem. 'Go to network access' -> 'IP whitelist' -> you can only connect to your cluster from those IP addresses , so if your IP is not present in that list

    Then Click the 'Add IP address' Button-> in there click the button 'Add your current IP address'.

    0 讨论(0)
提交回复
热议问题