Got error while connecting database

When I run my backend code It showed me this error: “queryTxt ETIMEOUT pwdbtest.swa3aiu.mongodb.net”.
My connection string is correct with the correct credentials. I also have updated my current IP address in my network security option, I couldn’t get why the error is persistent.
If anybody helps me to understand this issue.Thanks

Hi @Iram_Barkat, and welcome to the MongoDB Community forums! :wave:

Can you state if you are able to connect from the machine running your Node.JS application with the mongosh shell?

I would also double check that you’ve put the correct IP address in the allow list.

As a final test you could temporarily add 0.0.0.0 to the allow list to see if you’re able to connect from your application, just make sure you remove that so unwanted visitors cannot access your database once you’re testing has been completed.

Could you share the exact form you use? You may redact the credentials for security reasons. The error

seems to indicate a DNS issue. It might be caused by

  1. using the wrong connection string prefix
  2. using deprecated DNS servers that don’t know how to resolve seed list records

To solve point 2 you may try to use 8.8.8.8 Google’s DNS.

Thank you very much my problem is sorted out.

Could you please elaborate on how it was solved?

This would benefits all users of this forum.

Ad Thanks vance

1 Like

it was just IP address problem. IP address of my home network causing this problem.

how did you change it?

Make sure you have the correct external IP address. You can run a command such as curl ifconfig.me from a terminal window while connected to the machine you want to access MongoDB from. This will give you your machine’s external IP address. Once you have that, follow the instructions to add IP access list entries to your Atlas cluster.

1 Like

Thank you I have applied this command and also I add this IP address to my atlas cluster but shows me same error whenever I tried to connect from my home network

You can try the following:

  • Temporarily add 0.0.0.0/0. This is the button labeled Allow access from anywhere. Make sure to remove this access after you are done testing as you don’t want just anyone to be allowed to access your server, even with access control turned on. If this works, then you have not entered the correct IP address.
  • Temporarily disable your local firewall. How this is done depends on your OS and the firewall in place. If this works it means your machine is not allowing the requests out and you would need to research how to allow the traffic out (and potentially back in). Google will be your friend here.

S C:\Users\Alipser\Jugando Con el Front> curl ifconfig.me

StatusCode : 200
StatusDescription : OK
Content : 181.55.62.205
RawContent : HTTP/1.1 200 OK
access-control-allow-origin: *
x-envoy-upstream-service-time: 1
strict-transport-security: max-age=2592000; includeSubDomains
Content-Length: 13
Content-Type: text/plain; charset=…
Forms : {}
Headers : {[access-control-allow-origin, *], [x-envoy-upstream-service-time, 1], [strict-transport-security, max-age=2592000; includeSubDomains], [Content-Length, 13]…}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 13

I’m not sure what you’re asking here, but you would take the IP address (shown as Content in the results from PowerShell) and put that into the allow list in Atlas.

Doug, you are my best friend from now.

I allowed the IP address and also I allowed the 0.0.0.0./0 IP for connection from everywhere.
but I realized that mongod.exe were not starting right now I fixed that bug by creating a folder in local disk C:data/db.
Now it runs Mongod.exe

but it says: {“t”:{"$date":“2022-11-04T15:03:52.754-05:00”},“s”:“I”, “c”:“NETWORK”, “id”:23016, “ctx”:“listener”,“msg”:“Waiting for connections”,“attr”:{“port”:27017,“ssl”:“off”}}

I think that there is a problem with 27017 port

I am honored to have you consider me a friend. :heart:

This is normal. As the message states, the server is Waiting for connections. This means that you can connect to the server on port 27017. For a test run mongosh from a command prompt and you should be able to connect.

I do see that you’re running mongod locally on your your Windows machine. My instructions were for allowing connections to Atlas based instances. :wink:

Doug I figured out the problem is with my internet provider I changed the network I got connected

My firewall was off while doing testing. let me again check with “Allow access from anywhere” .
yet While doing testing again, I conclude my nodemon is not working, it showing me an error or “connection fail”.It seems the server is not being connected with localhost. Can you please help me to understand why is this happening?