Getting Time out, Connection refused by the server (Strange behavior)

1,417 views
Skip to first unread message

José Solano

unread,
Apr 6, 2018, 3:22:29 AM4/6/18
to mongodb-user

Hi guys,


I was working with Mongo DB 3.4.2, and I am facing an strange issue when accessing data from my API. The error message says:

"ClassName": "System.TimeoutException",
        "Message": "A timeout occured after 30000ms selecting a server using 
CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector,
 LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. 
Client view of cluster state is { ClusterId : \"1\", 
ConnectionMode : \"Automatic\", Type : \"Standalone\", State : \"Disconnected\", 
Servers : [{ ServerId: \"{ ClusterId : 1, EndPoint : \"ServerIp:27017\" }\", 
EndPoint: \"ServerIp:27017\", State: \"Disconnected\", Type: \"Unknown\", 
HeartbeatException: \"MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
 ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it


And we have already verified the following:

  • There is no block port on the server.
  • The firewall is not blocking the port.

The issue is solved by restarting the Mongo Db Service on the server, however the same issue comes up every 1 hour after restarting the service.

Could you please help me with this,

Thanks,

Jose


Kevin Adistambha

unread,
Apr 18, 2018, 3:04:16 AM4/18/18
to mongodb-user

Hi Jose

The error No connection could be made because the target machine actively refused it is typically the result of the service being offline, e.g., the machine itself is reachable, but the port is not open. During this time, can you connect to the server using the mongo shell?

If you are sure that the port is not blocked and there is no firewall blocking the port, the mongod process might be offline. One possibility is that the mongod process using up memory, and got killed by the OOMKiller (if running on a Linux server). This is typically the case when the server is lacking in RAM and/or having no swap configured. You can determine if this is the case by looking at your server’s system log. Typically, the message looks like:

Out of memory: Kill process <PID>
Killed process <PID>

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages