Sudden connection Error on Mongodb Atlas using nextjs app

This always happens when I’m developing and has been a brick wall for me. My connection to mongodb atlas becomes an error suddenly even tho I change back my code to the time the connection is doing good.
im not sure how to do this. Sometimes restarting my computer and getting a new connection string from atlas works. But I want to know what causes this or whats the direct solution for it

 ⨯ unhandledRejection: Error: querySrv EREFUSED        
    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:251:17)
    at QueryReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: undefined,
  code: 'EREFUSED',
  syscall: 'querySrv',
  hostname: ''

Hi @Daniel_Paragas and welcome to MongoDB community forums!!

The error here seems to occur when the connection string is not an srv string.
However, in order to help you further, could you help me with the following information:

  1. The connection string you are using?
  2. The MongoDB and the Driver version you are using?
  3. A code snippet where you are trying to connect to the database?
  4. Are you seeing any specific error in the database logs while you are trying to make the connection.