I tried to connect mongodb atlast web to my hosting server bu int server log i got this error
Error connecting to MongoDB: 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: /.mongodb..........
at _handleConnectionErrors
at NativeConnection.openUri
at process.processTicksAndRejections{
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(3) {
'ac-gekkiwz-shard-00-00.jeluhwd.mongodb.net:27017' => [ServerDescription],
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'atlas-jqkukr-shard-0',
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
server.js
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const path = require('path');
const bodyParser = require('body-parser');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.static(path.join(__dirname)));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
mongoose
.connect(process.env.MONGODB_URI, {
}).then(() => {
console.log(`Connected to MongoDB`);
app.listen(PORT, () => {
console.log(`Node API app is running on port ${PORT}`);
});
})
.catch((error) => {
console.error('Error connecting to MongoDB:', error);
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(PORT, () => {
console.log(`Node API app is running on port ${PORT}`);
});
however I whitelisted all of my IPs, properly, please help