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');


    res.send('hello there');

    console.log("Connected to DB");
    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:
    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) {
      '' => [ServerDescription],
      '' => [ServerDescription],
      '' => [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: 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.