MongooseServerSelectionError but I've done all I could to fix it

So basically I’m trying to follow up yt tutorials about node.js projects and a lot of them require mongodb atlas. This is not a problem for me. But the issue is some error I get when I execute the code. For example, here is my index.js (main) file which has a basic connection function:

const express = require('express')
const app = express()
const mongoose = require('mongoose');


app.listen(3000,()=>{
    console.log('server');
})

app.get('/',(req,res)=>{
    res.send('hello there');
})

mongoose.connect('mongodb+srv://<username>:<password>@backenddb.8r3rimb.mongodb.net/Node-API?retryWrites=true&w=majority&appName=BackendDB')
.then(()=>{
    console.log("Connected to DB");
})
.catch((err)=>{
    console.log("Connection failed -",err);
})

NOTE: I did change the username and password to the database cluster one in database access

And on executing, I get the following error:

Connection failed - 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 (C:\Users\NithilanGandhi\Desktop\simple-crud-app\node_modules\mongoose\lib\connection.js:896:11)
    at NativeConnection.openUri (C:\Users\NithilanGandhi\Desktop\simple-crud-app\node_modules\mongoose\lib\connection.js:847:11) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-miuakcv-shard-00-00.8r3rimb.mongodb.net:27017' => [ServerDescription],
      'ac-miuakcv-shard-00-01.8r3rimb.mongodb.net:27017' => [ServerDescription],
      'ac-miuakcv-shard-00-02.8r3rimb.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-103rsk-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}

I’ve tried setting my network access to all access, mine personal ip, everything. Still not fixed. I thought the port 27017 might be a prblm and tried running the link: http://portquiz.net:27017 in my browser and the curl command in cmd prompt. These fail to connect to server or site cannot be reached. So I have an idea of where the problem mihgt be. I tried to go to windows firewall settings and go to inbound rules, add new rule and allow all port access. I even turned off private,public and domain firewalls. still not able to connect to the port. Im really stuck here and Im a beginner. Please help me out.

Anyone find a solution to this yet?