MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017
2018-11-13T08:14:09.098-0600 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
exception: connect failed
HI Memory Nyandoro,
If I get this error, I will double-check if my
mongod is running on my localhost (127.0.0.1) and on port 27017 is free to use.
And after that, if your firewall will let you through.
Mind you, I’m curious why you’re connecting to localhost. I don’t recall M001 using a local MongoDB? I thought we only used the shared student cluster and our private clusters on Atlas.
Which exercise are you working on?
@Memory_38914 Did you just type “mongo” at the shell prompt by chance? I think it will try to connect to a mongoldb server instance on your localhost if no other connection information is specified. If you are trying to connect to one of the class clusters (either the pre-made one or the atlas cluster one we created) you will want to launch the shell with something closer to this;
>mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/100YWeatherSmall?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
If you are just trying to launch the shell without connecting use this:
Good point! That’d be it
Came here as this was exactly the problem I was having, thanks for the solution!
I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.
Curriculum Support Engineer