10
votes

enter image description here .> mongo

MongoDB shell version v3.6.5 connecting to: mongodb://127.0.0.1:27017 2018-06-26T17:37:13.313+0530 I NETWORK [thread1] Socket recv() An established connection was aborted by the software in your host machine. 127.0.0.1:27017 2018-06-26T17:37:13.313+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: SocketException socket exception [RECV_ERROR] server [127.0.0.1:27017] 2018-06-26T17:37:13.313+0530 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017' : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed

6

6 Answers

4
votes

See Mongod logs to find the root cause. For me it was leaking connections from one of the clients, this is what I found in logs: NETWORK [listener] connection refused because too many open connections:

8
votes

This problem can happen when trying to connect to a database which requires SSL.

3
votes

This error is usually caused by attempting to connect without SSL to a MongoDB server that requires it. Use the following command to connect:

mongo --ssl --username "$USERNAME" --password "$PASSWORD" --host "$HOST" --port  "$PORT"
0
votes
  1. just go simply on task manager and click on service

see given image below to copy the link on the URL enter image description here

  1. find MongoDB and click on open Service.

see given image below to copy the link on the url enter image description here

  1. then again find MongoDB and start stopped DB to running mode just click on green point button and you MongoDB is again started connecting.

[see given image below to copy the link on the url]

0
votes

In my case , I was running several applications on other ports. The above solutions did not worked well for me .
Finally I closed all the tabs of code editor and web-app , and restarted it . Now it works fine .

Well! You can just restart the system, that will also work with least hassle.

0
votes

As stated, this can happen because the server requires TLS in the connection. You will see the reason in server logs.

For someone who ends here without knowing how to fix it (like me) it's worth noting how to connect to those servers:

In command line you can use the --tls option (https://docs.mongodb.com/manual/tutorial/configure-ssl-clients/)

mongo --tls [other params and/or connection string]

If using a connection string alone, you can add tls=true param:

mongo://[user]:[pass]@[host]/[db]?tls=true[&others]