Unable to connect to MongoDB Replica Set using public IP addresses










0















I have configured a three-node replica set in MongoDB; replication is in sync.



I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this:




mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




But when I try to connect to the replica set using the servers' public IP addresses, like this:




mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




I get an error: "No primary detected for set rs0".










share|improve this question



















  • 1





    This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

    – Neil Lunn
    Jun 13 '17 at 5:49















0















I have configured a three-node replica set in MongoDB; replication is in sync.



I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this:




mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




But when I try to connect to the replica set using the servers' public IP addresses, like this:




mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




I get an error: "No primary detected for set rs0".










share|improve this question



















  • 1





    This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

    – Neil Lunn
    Jun 13 '17 at 5:49













0












0








0








I have configured a three-node replica set in MongoDB; replication is in sync.



I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this:




mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




But when I try to connect to the replica set using the servers' public IP addresses, like this:




mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




I get an error: "No primary detected for set rs0".










share|improve this question
















I have configured a three-node replica set in MongoDB; replication is in sync.



I am able to connect to each server individually, and using each server's private IP address I can to connect to the replica set like this:




mongo --host rs0/10.X.X.X:27017,10.X.X.X:27017,10.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




But when I try to connect to the replica set using the servers' public IP addresses, like this:




mongo --host rs0/52.X.X.X:27017,52.X.X.X:27017,52.X.X.X:27017 -u root -p abc123 --authenticationDatabase admin




I get an error: "No primary detected for set rs0".







mongodb networking mongodb-replica-set






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 14 '17 at 15:28









Vince Bowdren

4,34721841




4,34721841










asked Jun 13 '17 at 5:47









shyam rakhechashyam rakhecha

52




52







  • 1





    This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

    – Neil Lunn
    Jun 13 '17 at 5:49












  • 1





    This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

    – Neil Lunn
    Jun 13 '17 at 5:49







1




1





This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

– Neil Lunn
Jun 13 '17 at 5:49





This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here.

– Neil Lunn
Jun 13 '17 at 5:49












3 Answers
3






active

oldest

votes


















1














When you connect to the replica set, you should use the same addresses (ip addresses or host names) as the nodes use for each other in the replica set configuration. For replica set deployment, you need to:




Ensure that network traffic can pass between all members of the set and all clients in the network securely and efficiently.




In practice, it is best not to configure your replica set using public ip addresses; it is more secure to use the private ip addresses, which helps ensure that your database can only receive connections from authorised locations.






share|improve this answer






























    0














    this might be one of the reason.



    You should add all 3 servers public IP in to the bind ip values in all 3 servers /etc/mongod.conf



    if your are using AWS, you need to allow all this IP for inbound access to another server.






    share|improve this answer






























      0














      Thanks guys for responses,
      It needed to configure replica with public Ips in rs.config






      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44513233%2funable-to-connect-to-mongodb-replica-set-using-public-ip-addresses%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        When you connect to the replica set, you should use the same addresses (ip addresses or host names) as the nodes use for each other in the replica set configuration. For replica set deployment, you need to:




        Ensure that network traffic can pass between all members of the set and all clients in the network securely and efficiently.




        In practice, it is best not to configure your replica set using public ip addresses; it is more secure to use the private ip addresses, which helps ensure that your database can only receive connections from authorised locations.






        share|improve this answer



























          1














          When you connect to the replica set, you should use the same addresses (ip addresses or host names) as the nodes use for each other in the replica set configuration. For replica set deployment, you need to:




          Ensure that network traffic can pass between all members of the set and all clients in the network securely and efficiently.




          In practice, it is best not to configure your replica set using public ip addresses; it is more secure to use the private ip addresses, which helps ensure that your database can only receive connections from authorised locations.






          share|improve this answer

























            1












            1








            1







            When you connect to the replica set, you should use the same addresses (ip addresses or host names) as the nodes use for each other in the replica set configuration. For replica set deployment, you need to:




            Ensure that network traffic can pass between all members of the set and all clients in the network securely and efficiently.




            In practice, it is best not to configure your replica set using public ip addresses; it is more secure to use the private ip addresses, which helps ensure that your database can only receive connections from authorised locations.






            share|improve this answer













            When you connect to the replica set, you should use the same addresses (ip addresses or host names) as the nodes use for each other in the replica set configuration. For replica set deployment, you need to:




            Ensure that network traffic can pass between all members of the set and all clients in the network securely and efficiently.




            In practice, it is best not to configure your replica set using public ip addresses; it is more secure to use the private ip addresses, which helps ensure that your database can only receive connections from authorised locations.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 14 '17 at 15:37









            Vince BowdrenVince Bowdren

            4,34721841




            4,34721841























                0














                this might be one of the reason.



                You should add all 3 servers public IP in to the bind ip values in all 3 servers /etc/mongod.conf



                if your are using AWS, you need to allow all this IP for inbound access to another server.






                share|improve this answer



























                  0














                  this might be one of the reason.



                  You should add all 3 servers public IP in to the bind ip values in all 3 servers /etc/mongod.conf



                  if your are using AWS, you need to allow all this IP for inbound access to another server.






                  share|improve this answer

























                    0












                    0








                    0







                    this might be one of the reason.



                    You should add all 3 servers public IP in to the bind ip values in all 3 servers /etc/mongod.conf



                    if your are using AWS, you need to allow all this IP for inbound access to another server.






                    share|improve this answer













                    this might be one of the reason.



                    You should add all 3 servers public IP in to the bind ip values in all 3 servers /etc/mongod.conf



                    if your are using AWS, you need to allow all this IP for inbound access to another server.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 13 '17 at 12:23









                    Manivannan ThirugnanamManivannan Thirugnanam

                    449413




                    449413





















                        0














                        Thanks guys for responses,
                        It needed to configure replica with public Ips in rs.config






                        share|improve this answer



























                          0














                          Thanks guys for responses,
                          It needed to configure replica with public Ips in rs.config






                          share|improve this answer

























                            0












                            0








                            0







                            Thanks guys for responses,
                            It needed to configure replica with public Ips in rs.config






                            share|improve this answer













                            Thanks guys for responses,
                            It needed to configure replica with public Ips in rs.config







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 15 '17 at 17:31









                            shyam rakhechashyam rakhecha

                            52




                            52



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44513233%2funable-to-connect-to-mongodb-replica-set-using-public-ip-addresses%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Use pre created SQLite database for Android project in kotlin

                                Darth Vader #20

                                Ondo