0
MongoDB shell version v4.4.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: NetworkTimeout: Error connecting to 127.0.0.1:27017 :: caused by :: Socket operation timed out :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

Everytime when I run mongo command , it says error connecting to 127.0.0.1:27017 caused by socket opeartion timed out. Tried following many instructions given by peers , but it didn't work.

Hope I get rid of this by your instructions.

Thanks!

  • There is no open 27017 port at localhost. What are parameters what has been used when mongoD has started? Is mongod process really running? 'sudo ps -ef|grep mongod; sudo netstat -anp|grep mongod' – JJussi Jun 17 '21 at 09:13
  • Actually there is an open 27017 port, checked using commands in cmd & mongodb server is running , used mongod.exe command to start and mongo for connecting. But don't know why its not connecting . @JJussi – BhaveshReddy Jun 18 '21 at 11:10
  • OK.. You are running in the windows world. Check your "firewall", is the port 27017 open? Because that error comes when firewall is blocking traffic. – JJussi Jun 19 '21 at 07:35
  • I was thinking the same but I tried by shutting windows firewall off , added new inbound outbound connection rules to allow through it , none of these worked . Don't know why im facing this issue , Thanks for trying to solve @JJussi – BhaveshReddy Jun 20 '21 at 12:35

1 Answers1

0

Reason: mongodb service is not running

Run mongodb service method: Open the terminal and execute mongod -dbpath "D:\Program Files\MongoDB\data\db" ("D:\Program Files\MongoDB\data\db" is the directory you created to store data) Open another terminal and execute mongo