Fatal error: No suitable servers found

Fatal error : Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (serverSelectionTryOnce set): [Failed to receive length header from server. calling hello on ‘cluster0-shard-00-02.sw31d.mongodb.net:27017’] [Failed to receive length header from server. calling hello on ‘cluster0-shard-00-00.sw31d.mongodb.net:27017’] [Failed to receive length header from server. calling hello on ‘cluster0-shard-00-01.sw31d.mongodb.net:27017’] in C:\xampp\htdocs\php_mongdb\vendor\mongodb\mongodb\src\functions.php:520 Stack trace: #0 C:\xampp\htdocs\php_mongdb\vendor\mongodb\mongodb\src\functions.php(520): MongoDB\Driver\Manager->selectServer(Object(MongoDB\Driver\ReadPreference)) #1 C:\xampp\htdocs\php_mongdb\vendor\mongodb\mongodb\src\Collection.php(932): MongoDB\select_server(Object(MongoDB\Driver\Manager), Array) #2 C:\xampp\htdocs\php_mongdb\index.php(14): MongoDB\Collection->insertOne(Array) #3 {main} thrown in C:\xampp\htdocs\php_mongdb\vendor\mongodb\mongodb\src\functions.php on line 520

hi,
how can i fix this

1 Like

I believe you are using a url of the form mongo+srv:// instead of supplying all three cluster member addresses.

It is highly possible you are in your work network (or a cafe), and it is blocking access to Atlas cluster servers. if this is the case, you may ask you network admins to permit these connections. otherwise you need to change your internet access. for example use your mobile data, or use network at home or at a friend’s.

Hello @Gimhan_De_Silva, welcome to the community forum!

You can also include the code and the versions of the programming language, driver and the database you are working with. It is generally easy to figure the cause of the issue with all the available information.

Its not working please help with this problem

What is it “exactly” that is not working? please give us details we may work on. what code you use, what error you get, how, where and on what you run it, etc.