MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

If the Error states:

connect() Error :MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

Then the connection to localhost is refused on the IPv6 address ::1 .
Mongoose per default uses IPv6 ..

For a quick check you can set the IPv4 address explicit:

mongoose.connect('mongodb://127.0.0.1/test')

Leave a Comment