Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017'
This problem can happen when trying to connect to a database which requires SSL.
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: