Laravel Homestead with Mongodb: Failed to parse URI options: Failed to look up SRV record

Viewed 40

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

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.

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 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

0 Answers
Related