Working Well Locally What i am going to host i get these errors

https://messagebuzz.netlify.app/

Jun 25, 06:28:45 PM: a5eb4db2 ERROR Unhandled Promise Rejection {“errorType”:“Runtime.UnhandledPromiseRejection”,“errorMessage”:“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://www.mongodb.com/docs/atlas/security-whitelist/",“reason”:{“errorType”:“MongooseServerSelectionError”,“errorMessage”:"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://www.mongodb.com/docs/atlas/security-whitelist/",“message”:"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://www.mongodb.com/docs/atlas/security-whitelist/",“reason”:{“type”:“ReplicaSetNoPrimary”,“servers”:{},“stale”:false,“compatible”:true,“heartbeatFrequencyMS”:10000,“localThresholdMS”:15,“setName”:“atlas-uzep7s-shard-0”,“maxElectionId”:null,“maxSetVersion”:null,“commonWireVersion”:0,“logicalSessionTimeoutMinutes”:null},“stack”:["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://www.mongodb.com/docs/atlas/security-whitelist/“,” at _handleConnectionErrors (/var/task/node_modules/mongoose/lib/connection.js:875:11)”," at NativeConnection.openUri (/var/task/node_modules/mongoose/lib/connection.js:826:11)“,” at process.processTicksAndRejections (node:internal/process/task_queues:95:5)“]},“promise”:{},“stack”:[“Runtime.UnhandledPromiseRejection: 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://www.mongodb.com/docs/atlas/security-whitelist/“,” at process. (file:///var/runtime/index.mjs:1276:17)”,” at process.emit (node:events:517:28)“,” at emit (node:internal/process/promises:149:20)“,” at processPromiseRejections (node:internal/process/promises:283:27)“,” at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}Jun 25, 06:28:45 PM: [ERROR] [1719320325030] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 400.Jun 25, 06:28:45 PM: RequestId: 52b4c10f-aeb6-4820-bb8b-85fa3f8703d0 Error: Runtime exited with error: exit status 128
Runtime.ExitErrorJun 25, 06:28:45 PM: 52b4c10f Duration: 78.10 ms Memory Usage: 260 MB Jun 25, 06:28:50 PM: 9aadff58 ERROR Error: Failed to lookup view “error” in views directory “views”
at Function.render (/var/task/node_modules/express/lib/application.js:597:17)
at ServerResponse.render (/var/task/node_modules/express/lib/response.js:1048:7)
at sendErrorProd (/var/task/controllers/errorController.js:55:39)
at module.exports (/var/task/controllers/errorController.js:87:5)
at Layer.handle_error (/var/task/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/var/task/node_modules/express/lib/router/index.js:326:13)
at /var/task/node_modules/express/lib/router/index.js:286:9
at Function.process_params (/var/task/node_modules/express/lib/router/index.js:346:12)
at next (/var/task/node_modules/express/lib/router/index.js:280:10)
at next (/var/task/node_modules/express/lib/router/route.js:141:14)Jun 25, 06:28:50 PM: 9aadff58 Duration: 4412.51 ms Memory Usage: 198 MB

@nareshthapa The relevant error appears to be:

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.

You could search around to confirm yourself, but I suspect you’ll find that Netlify doesn’t have nor provide a single IP address that you could use to add to the whitelist.

Here’s a relevant old discussion:

1 Like