Greetings. This is my first implementation of a web app, and I’m not able to successfully deploy from GCP using a Compute Engine instance.
From mongodb, I have whitelisted the instance’s external IP address. Are there other reasons I could be getting this error?
$ nodemon server.js
[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
server started on port 8080
/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/connection.js:807
const serverSelectionError = new ServerSelectionError();
^
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
at NativeConnection.Connection.openUri (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/connection.js:807:32)
at /home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/index.js:340:10
at /home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
at new Promise (<anonymous>)
at promiseOrCallback (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
at Mongoose._promiseOrCallback (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/index.js:1140:10)
at Mongoose.connect (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/lib/index.js:339:20)
at file:///home/overlord/github_sleepywakes_thunderroost/server.js:28:10
at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
at async Loader.import (node:internal/modules/esm/loader:178:24) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
'cluster0-shard-00-00.geujl.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'cluster0-shard-00-00.geujl.mongodb.net',
port: 27017
},
address: 'cluster0-shard-00-00.geujl.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 634944,
lastWriteDate: 0,
error: MongoNetworkError: connection <monitor> to 35.184.107.131:27017 closed
at Connection.handleIssue (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:122:23)
at TLSSocket.<anonymous> (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:63:39)
at TLSSocket.emit (node:events:394:28)
at node:net:662:12
at TCP.done (node:_tls_wrap:580:7)
},
'cluster0-shard-00-01.geujl.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'cluster0-shard-00-01.geujl.mongodb.net',
port: 27017
},
address: 'cluster0-shard-00-01.geujl.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 636016,
lastWriteDate: 0,
error: MongoNetworkError: connection <monitor> to 35.232.161.204:27017 closed
at Connection.handleIssue (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:122:23)
at TLSSocket.<anonymous> (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:63:39)
at TLSSocket.emit (node:events:394:28)
at node:net:662:12
at TCP.done (node:_tls_wrap:580:7)
},
'cluster0-shard-00-02.geujl.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'cluster0-shard-00-02.geujl.mongodb.net',
port: 27017
},
address: 'cluster0-shard-00-02.geujl.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 634879,
lastWriteDate: 0,
error: MongoNetworkError: connection <monitor> to 35.192.112.82:27017 closed
at Connection.handleIssue (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:122:23)
at TLSSocket.<anonymous> (/home/overlord/github_sleepywakes_thunderroost/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:63:39)
at TLSSocket.emit (node:events:394:28)
at node:net:662:12
at TCP.done (node:_tls_wrap:580:7)
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'atlas-67keal-shard-0',
logicalSessionTimeoutMinutes: undefined
}
}
[nodemon] app crashed - waiting for file changes before starting...
This is the line from my code, using the cluster copied from mongodb.
mongoose.connect("mongodb+srv://overlord:mt5E%23c4b@cluster0.geujl.mongodb.net/ThunderDB", { useNewUrlParser: true});
Thank you in advance for any advice!