Hello, I am having trouble getting connected to my localhost MongoDB on Mac OS. I have read through countless forums and tried everything to get mongod and the mongodb-community server started, but nothing has worked. The error I am getting is below:
const serverSelectionError = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017`
Can anyone help me with this please?
51 Likes
Is your mongod up and running on port 27017?
Can you connect by another tool like shell or Compass?
i have the same problem only when connecting in my nodejs app, but when connecting using shell or Compass there is no problem,
3 Likes
I just found a solution in the internet ,
If you are using latest nodejs (v17.x) , then try updating mongodb url from localhost to 127.0.0.1
This worked for me
142 Likes
That worked for me too bro, thank you. <3
3 Likes
Thanks bro , it worked for me also
@Danaboina_Shanmukeshwar YOU’RE THE MAN!!! Thanks a lot. Worked for me very well.