Mongodb: Failed to parse URI options: Failed to look up SRV record


Before writing this topic, I asked for support in the forum and there they suggested I ask here.

I am using laravel homestead and was able to configure almost everything I needed (virtualbox).

I am experiencing this problem: I installed the php driver to connect with mongodb and tried to create a small project in laravel by adding the jenssegers/mongodb library.

The mongodb database is on the atlas servers (Serverless).

I entered the string that allows me to connect to the database like this:

new MongoDB\Client('mongodb+srv://')

If I try to connect I get this error:

Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse URI options: Failed to look up SRV record "": The requested name is valid but does not have an IP address.

I tried to skipping srv including complete query from the srv record but I get this other error:

Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (serverSelectionTryOnce set): [Failed to resolve '']

I have tried the same configuration on a digital ocean server and I do not encounter any problems.

Can anyone help me solve the problem?