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

Hi.

Before writing this topic, I asked for support in the laracasts.com 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://user:password@db.7h4dt.mongodb.net')

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 "_mongodb._tcp.db.7h4dt.mongodb.net": 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 'db.7h4dt.mongodb.net']

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?

Thanks