Error: querySrv ESERVFAIL _mongodb._tcp.cluster0.abcd0.mongodb.net - mongodb

My nodejs app was working fine with mongodb connection and suddenly this error got appeared. Then I tried to connect to mongodb with mongo compass and same error is there. I could not find out any reason for this.
Error: querySrv ESERVFAIL _mongodb._tcp.cluster0.abcd0.mongodb.net
[nodemon] app crashed - waiting for file changes before starting...
Then I changed the mongodb connection url to old url and after that I got this error.
Error: 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://docs.atlas.mongodb.com/security-whitelist/
[nodemon] app crashed - waiting for file changes before starting...
I have already white listed my ips and my configurations are correct (I double checked).
0.0.0.0/0 (includes your current IP address)
What is the reason for this ?
Thank you.

querySrv ESERVFAIL is a DNS error.
This means that your local machine is not able to get a response from your DNS resolver for the SRV record _mongodb._tcp.cluster0.abcd0.mongodb.net (I assume that's not your real hostname, but it will work for an example)
From your local machine, test SRV lookup from a command line, possibly one of these:
nslookup -type=SRV _mongodb._tcp.cluster0.abcd0.mongodb.net
host -t SRV _mongodb._tcp.cluster0.abcd0.mongodb.net
If that fails, feel free to say bad things about your DNS provider.
Then go to the Atlas UI and get the pre-3.6 connection string. It will start with mongodb:// and not mongodb+srv://.

Joe's identification of the problem is spot on and help me with a resolution. This was fixed for me after adding Google's DNS server (8.8.8.8) to the Wifi settings of my computer.
On MacOS its in Settings > Network > Wi-Fi (select the appropriate network) > Advanced > DNS
Then add the DNS Server 8.8.8.8

I was a windows10 user and I was facing exactly the same problem. I have figure out it's a DNS problem. the following process worked for me
Check this! if you are non windows 10 user

Stop the server and run again your server and it will solve the problem.

Hey Guys!
So i was having this weird error below :(
So what might be causeing this error?
make sure the database you trying to create n your mongoDB collections exist for me it was "userDB" that was the issue for me!
mongoose.connect(
`mongodb+srv://admin-eniola:${process.env.PASSWORD}#cluster0.velr6at.mongodb.net/userDB`
);
makes sure you check whatever password you using, it must correlate with your user password not account password!
check where your password is stored your program either dotenv or secrets file and make sure it match with your user account password.
Thanks and i hope this solutions works for you as well!

Related

gcloud beta sql connect "server closed the connection unexpectedly"

When trying to get a psql shell (not using iam user) I am receiving:
> gcloud alpha sql connect pg-instance --database mydb --user myuser --project my-project
Starting Cloud SQL Proxy: [/Users/me/google-cloud-sdk/bin/cloud_sql_proxy -instances my-project:us-central1:pg-instance=tcp:9470 -credential_file /Users/me/.config/gcloud/legacy_credentials/me#me.com/adc.json]]
2022/03/15 14:47:59 Rlimits for file descriptors set to {Current = 8500, Max = 9223372036854775807}
2022/03/15 14:47:59 using credential file for authentication; path="/Users/me/.config/gcloud/legacy_credentials/me#me.com/adc.json"
2022/03/15 14:48:00 Listening on 127.0.0.1:9470 for my-project:us-central1:pg-instance
2022/03/15 14:48:00 Ready for new connections
Connecting to database with SQL user [myuser].Password:
psql: error: connection to server at "127.0.0.1", port 9470 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I had the same error message when connecting to Postgres(Cloud Sql) using a service account.
In my setup I did run cloud_sql_proxy inside docker container.
In order to make it work I had to add extra configuration defined in step #9 https://cloud.google.com/sql/docs/sqlserver/connect-docker#connect-client
docker run -d \
-v <PATH_TO_KEY_FILE>:/config \
-p 127.0.0.1:5432:5432\
gcr.io/cloudsql-docker/gce-proxy:1.33.1 /cloud_sql_proxy \
-instances=<INSTANCE_CONNECTION_NAME>=tcp:0.0.0.0:5432 -credential_file=/config
The missing bits were: host ip on port mapping and 0.0.0.0: in cloud_sql_proxy command
There are a few things I would like to point out. The best starting point for me would be the About connection options page; both the Overview and the Before you begin sections are very helpful to get the full idea of the process and how to properly configure the user. But the most important part is the Connection Options, for the message connection to server at "127.0.0.1" I’m guessing it is a private IP, but please make sure this section is covered before starting to debug.
In your case, the logs are saying there was an error in the connection to the server…
I used the Troubleshoot guide that includes the Diagnose issues link to get to the Debug connection issues page that has a lot of useful information on how to debug any connectivity issue.
Generally, connection issues fall into one of the following three areas:
Connecting - are you able to reach your instance over the network?
Authorizing - are you authorized to connect to the instance?
Authenticating - does the database accept your database credentials?
Each of those can be further broken down into different paths for investigation.
Once determining the connection method, there are different questions that will help to guide you through the possible troubleshooting paths.
If using these guides doesn’t get you a solution, please make sure to update your answer with the results, steps, and information followed to provide further help. This would be a good example, as it has the same log error, and this other question shows that there are a few different troubleshooting paths for this specific log message, plus they have useful information for you.

I cant connect to AWS RDS using Postgres

Ive created an instance/database on aws and when I try to connect to it through my terminal, by running the code below, I get an error.
The line I run in the terminal is:
psql --host=testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com --port=5432 --username=postgres --password --dbname=testdb
And the error it returns is:
psql: error: could not connect to server: could not translate host name "testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com"
to address: nodename nor servname provided, or not known.
Ive spent the last 3 days reading the relevant documentation and trying to get this to work but I don't know where im going wrong.
Also when I run:
nslookup testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com
It returns:
Non-authoritative answer:
*** Can't find testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com: No answer
I come from a statistics background and I've done a fair bit of coding in R and python but Im relatively new to using the terminal etc!
Thanks for any guidance or help as this is making me want to punch my laptop.
On running dig command:
dig testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com
It returned a private IP: 172.31.23.42.
It seems you are running RDS instance as private or internal, i.e. it won't be accessible from the internet.
You need to access it from the VPC itself or need to use a VPN.
Seems like its a DNS resolution issue. I was able to resolve it using DIG.
In the VPC make sure that both of the following options are enabled on the VPC:
enableDnsHostnames
enableDnsSupport
If the RDS instance is not hosted in the VPC but is instead accessed across a VPC peer then DNS resolution might need enabling on the VPC peer

why are wekan calls to mongodb unable to connect?

I recently installed Manjaro and followed this tutorial: https://snapcraft.io/install/wekan/manjaro to install wekan. Everything went slicker than snot. I registered an account no issues, open the weken webgui at port 8080 without issue, create new lists and cards fine, but when I go to open the cards I create the connection to 127.0.0.1 is refused. Although it doesn't specify a port, I assume this is a call to the mongodb at the default port 27017, but I also opened up 28017 in the firewall.
Although mongo definitely seems to have been installed since I can see it is running, I can't find a mongod*.conf file on the system to verify the default ports.
This is the first time I used “snap” to install anything, and because it all went so seamlessly I have no clue where to start looking to find the issue. Is there a utility in snap where I can find out exactly what was installed to support wekan (webserver, database, etc.) that I can start checking into as potentials sources of issue. Thks.

Yarn: Error: connect ECONNREFUSED 127.0.0.1:443

When I install ELM via yarn, I get
-- ERROR -----------------------------------------------------------------------
Something went wrong while fetching the following URL:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-windows-64-bit.gz
It is saying:
Error: connect ECONNREFUSED 127.0.0.1:443
NOTE: You can avoid npm entirely by downloading directly from:
https://github.com/elm/compiler/releases/download/0.19.1/binary-for-windows-64-bit.gz
When I manually browse to https://github.com/elm/compiler/releases/download/0.19.1/binary-for-windows-64-bit.gz. I get
However other people can access the link and it downloads the file.
EDIT:
HOSTS File:
127.0.0.1 view-localhost # view localhost server
127.0.0.1 mydevsnapcap.com www.mydevsnapcap.com app.mydevsnapcap.com internal.mydevsnapcap.com
0.0.0.1 mssplus.mcafee.com
Edit
This use to work a few days ago.
More tests:
I cannot access it from my phone and pc using my fibre connection, but I can access it on both my phone and mobile using my mobile connection.
It turns out that it was my ISP that was for some reason blocking the link. I switch to using the google dns and all is good in the hood: https://developers.google.com/speed/public-dns/docs/using
Something in your computer or on your network is resolving the domain github.com to 127.0.0.1, i.e. localhost. Hence, everytime you attempt this access, it tries to reach a service running on the very same computer you're making the request from.
Check your DNS settings.
Check that there are no entries for github.com in the hosts file (on Windows C:\Windows\System32\drivers\etc\hosts, everywhere else /etc/hosts).
If you're running something like Pi-Hole on your network, check, that it doesn't catch github.com

Error when using mongoose.connect on AWS EC2 server

I've installed Node, express, and mongodb all successfully. I can run mongo in my terminal and it starts correctly. I can also see data i've manually stored.
Locally, I was using mongoose.connect('mongodb://localhost:27017/test'); and I had no issues. On my EC2 I used mongoose.connect('mongodb://ipaddress:27017/test'); but it's failing.
Error: failed to connect to [ipaddress:27017].
ipaddress is an actual ip address not a string or variable.
mongo
show dbs <-- this shows my databases so I know it's running!
I've looked online for a few hours and have come up short! I'm sure it's a simple setting i've missed.
On my EC2 i'm allowing all connections on all port ranges.
What am I missing?
Thanks!
Since the mongod instance is running on the same server, you need to set the IP Address to 0.0.0.0
I'm not sure why this needs to be done, but I got (some) understanding by reading the explanations listed on this post.