I’m trying to connect to Mongo Atlas using PHP and I get the following error:
Could not establish stream for node servername:27017: [connection closed calling hello on 'servername:27017']
I have searched high and low and can’t find anyone with his error exactly. I’ve tried looking at SSL issues, but nothing helped. I am able to connect using mongo cli.
Centos 7 with PHP 7 on Apache 2.
February 10, 2023, 6:52pm
Please post your PHP code including the mogodb uri you are using to connect
BUT be sure to obscure your username and password!!
@Everett_Glovier and welcome to the MongoDB community!
It would be nice to have more information, but what you are seeing might be the result of something in the earlier initialization that went undetected. I wrote an article about MongoDB PHP Error handling, that might give you checking ideas.
This article shows you common mechanisms to deal with potential PHP Errors and Exceptions triggered by connection loss, temporary inability to read/write, initialization failures, and more.
Let us know!