Signup/Sign In
MARCH 14, 2023

[SOLVED] Failed to parse URI options: Failed to look up SRV record - MAMP Server

Technology #mongodb#MAMP#howto

    If you are trying to connect with your Mongodb cloud cluster, using a connection string that looks like this:

    mongodb+srv://<username>:<password>@cluster0.abcdef.mongodb.net/your_db?retryWrites=true&w=majority

    And you get the following error while trying to setup the connection,


    Connection failed: Failed to parse URI options: Failed to look up SRV record "_mongodb._tcp.cluster0.abcdef.mongodb.net": A temporary error occurred on an authoritative name server. Try again later.

    Then you are at the right place.

    If you are getting this issue using PHP and MAMP server, then a small configuration change in the MAMP server will solve this issue.

    Fix for the Error

    While looking for a solution on Google you will find many articles, and webpages talking about this issue, but trust me, none of them will help you out. Because I tried them all when I first got this issue.

    The fix for this error is simple. If you are using MAMP server with the default port configuration, that means your localhost opens up at the URL localhost:8888, then all you have to do is change the ports being used.

    In you MAMP window, click on Preferences (at the top-left corner):

    MAMP preference change

    Then click on the button that says 80 and 3306, this will change the default web server port to 80 and MySQL port to 3306 for the MAMP server.

    MAMP server default ports

    Then restart the MAMP server.

    Your problem should be resolved.

    Conclusion

    That's it, some problems have very simple solutions if you are looking at the correct place.

    Hope this article helps your esolve your error and successfully setup connection with your mongoDB cluster.

    I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight
    IF YOU LIKE IT, THEN SHARE IT
    Advertisement

    RELATED POSTS