Intermittent connection errors on PHP

Hello community,

I hope someone will be able to help me debug some connection errors in our PHP application.

Our connection between PHP and MongoDB is working fine most of the time. However, some requests fail with either the following error messages:

  • No suitable servers found (serverSelectionTryOnce set): [socket timeout calling ismaster on ‘:27017’]
  • No servers yet eligible for rescan

I have found multiple mentions of these errors online, but they all deal with situations where every requests fails. I haven’t found a reason yet why most requests would work normally, but some fail.

Our environment:

  • Mongo server 4.4 (single instance, no cluster)
  • Mongo PHP driver 1.8.2
  • Mongo PHP library 1.8.0

What can I do to debug this issue?

did you find a resolution?

Unfortunately not @Dominic_Taylor . Tweaking timeout seemed to reduce it a bit, but I didn’t manage to get rid of those errors completely.

1 Like

it will be great finding a solution on this

Welcome to the MongoDB community forums @Diego_Chicaiza !

@Freek_Vandeursen , are you using a self-hosted MongoDB server?

I was also wondering if this happens when under heavy load, or just randomly when there’s no reason to run out of available connections/resources that might cause intermittent issues. What’s an approximate ratio of success vs. fail in your opinion?

Hello, have you found a solution for this error? The same thing is happening to me. I have PHP version 7.4 and I’m using the mongo driver with version 1.6.1

Bonjour, je rencontre exactement le même problème. Le serveur MongoDB n’est pas installé sur mon serveur comme j’utilise ScaleGrid. J’ai installé uniquement le driver PHP officiel pour MongoDB. La plupart du temps ça fonctionne mais très aléatoirement je rencontre l’erreur : PHP Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (serverSelectionTryOnce set): [Failed to resolve ‘’] [Failed to resolve ‘’] [Failed to resolve ‘’]

J’utilise MongoDB 4.2 et le driver PHP 1.15.0 (je viens de le mettre à jour vers 1.17.2 pour voir si ça change quelque chose).

@alexis_bonnyaud The error message points towards failure in resolving the domain. Are you able to perform ping/nslookup to the server domain from your host machine to this server when this error is hit? I suspect this server or your machine maybe suffering from network connectivity issues.

Le message d’erreur apparait de temps en temps dans mes logs mais je ne l’ai jamais vécu par moi même donc je n’ai pas pu tester. Cependant j’ai quand même contacté ScaleGrid (qui gère la base de donnée) et ils m’indique n’avoir reçu aucune erreur de leur coté. Je vais essayé de mettre l’option “serverSelectionTryOnce” à false pour voir si ça change quelque chose…

Any progress on this issue?