Skip to content

MongooseError [MongooseServerSelectionError]: getaddrinfo EAI_AGAIN – How to fix?

In this small post, let’s see how to resolve getaddrinfo EAI_AGAIN error when you try to connect to a database in mongo using Mongoose or other mongo libraries.

This error probably occurs because your Mongo DB connection URI is wrong.


Let’s consider the above Mongo connection URI that you use to connect to your Mongo Database.

If you get getaddrinfo EAI_AGAIN error when you connect to your database, please check the following.

  • If username and password are correct
  • The Mongo URL is in the correct format. i.e. mongodb://username:password@host:port/db
  • The host is accessible and your network connectivity is good.
  • You have the specified database in mongo.

See also  MongoDB Import JSON Error – Unmarshaling Bytes

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.