summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2019-03-07 11:50:13 -0500
committerMathias Stearn <mathias@10gen.com>2019-05-02 14:52:31 -0400
commit9bd646a2fb193698e40ae284f1f95bd70e8b55a4 (patch)
tree37c1180ccfca843101f1c329cd7275598182b160
parente3d7e744ddb1ea3f72ea14efa9ab8769e463024f (diff)
downloadmongo-9bd646a2fb193698e40ae284f1f95bd70e8b55a4.tar.gz
SERVER-38625 When the shell fails to connect to an Atlas cluster, tell the user to check their IP whitelist
(cherry picked from commit ef5c6c6f837cc317bd048db29948ca387517ef25)
-rw-r--r--src/mongo/shell/mongo.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index e0be81a6b56..aa16d004d12 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -340,7 +340,16 @@ connect = function(url, user, pass) {
safeURL = url.substring(0, protocolPos + 3) + url.substring(atPos + 1);
}
chatty("connecting to: " + safeURL);
- var m = new Mongo(url);
+ try {
+ var m = new Mongo(url);
+ } catch (e) {
+ if (url.indexOf(".mongodb.net") != -1) {
+ print("\n\n*** It looks like this is a MongoDB Atlas cluster. Please ensure that your" +
+ " IP whitelist allows connections from your network.\n\n");
+ }
+
+ throw e;
+ }
var db = m.getDB(m.defaultDB);
if (user && pass) {