Unable to connect to MongoDB Replica Set using public IP addresses
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
add a comment |
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
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
add a comment |
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
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
mongodb networking mongodb-replica-set
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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.
add a comment |
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.
add a comment |
Thanks guys for responses,
It needed to configure replica with public Ips in rs.config
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Jun 14 '17 at 15:37
Vince BowdrenVince Bowdren
4,34721841
4,34721841
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jun 13 '17 at 12:23
Manivannan ThirugnanamManivannan Thirugnanam
449413
449413
add a comment |
add a comment |
Thanks guys for responses,
It needed to configure replica with public Ips in rs.config
add a comment |
Thanks guys for responses,
It needed to configure replica with public Ips in rs.config
add a comment |
Thanks guys for responses,
It needed to configure replica with public Ips in rs.config
Thanks guys for responses,
It needed to configure replica with public Ips in rs.config
answered Jun 15 '17 at 17:31
shyam rakhechashyam rakhecha
52
52
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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