mongodb dump fails with cannot unmarshal DNS message - mongodb

I am using a mongo db server version MongoDB shell version v4.0.16 installed on a EC2 instance.
I am able to get into the instance using mongo command
mongo mongodb+srv://dxxxxxxx:xxxxxx[][]#cluster0-vxcen.gcp.mongodb.net
MongoDB shell version v4.0.16
connecting to: mongodb://cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017/?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2020-03-05T09:02:45.265+0000 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017
2020-03-05T09:02:45.604+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017 (1 connections now open to cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017 with a 5 second timeout)
2020-03-05T09:02:45.607+0000 I NETWORK [js] Successfully connected to cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017 (1 connections now open to cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017 with a 5 second timeout)
2020-03-05T09:02:45.707+0000 I NETWORK [js] changing hosts to Cluster0-shard-0/cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017,cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 from Cluster0-shard-0/cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017
2020-03-05T09:02:46.010+0000 I NETWORK [js] Successfully connected to cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
2020-03-05T09:02:46.028+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
2020-03-05T09:02:46.439+0000 I NETWORK [js] Successfully connected to cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { "id" : UUID("1c7432d5-e09c-45f8-8d84-d47e4f572cbf") }
MongoDB server version: 4.2.3
WARNING: shell and server versions do not match
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise Cluster0-shard-0:PRIMARY>
I am trying to connect to a mongo db Atlas to get the database using mongodump
mongodump --uri="mongodb+srv://dxxxxxxx:xxxxxx[][]#cluster0-vxcen.gcp.mongodb.net/xxxxxxxxxx"
I am facing issues with
error parsing command line options: error parsing uri (mongodb+srv://dxxxxxxx:xxxxxx[]#cluster0-vxcen.gcp.mongodb.net/xxxxxxxxxx): lookup cluster0-vxcen.gcp.mongodb.net on 127.0.0.53:53: cannot unmarshal DNS message

This is just a case of incompatible DNS server.
Locate /etc/resolv.conf file and replace the nameserver with 8.8.8.8, and everything should work just fine. If that does not work , try 1.1.1.1.

This issue is simmilar to the one reported here.
The fix for changing resolv.conf as above seems not to persist reboots.
The workaround proposed in the link above is either to use non srv url, or, a simpler way that and as far as I have seen survives reboots as well, is to remove the symlink /etc/resolve.conf and replace it with a static file containing the required DNS server.
Another option, found here
Suggests installing resolvconf (for Ubuntu apt install resolvconf), add the line nameserver 8.8.8.8 to /etc/resolvconf/resolv.conf.d/base, then run sudo resolvconf -u and to be sure service resolvconf restart.
To verify run systemd-resolve --status.
You should see on the first line your DNS server like here:
DNS Servers: 8.8.8.8
DNS Domain: sa-east-1.compute.internal
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa

Two solutions that worked for me:
Add nameserver with value 8.8.8.8 or 1.1.1.1 additionally to existing ones in /etc/resolve.conf file
Use connection string in format mongodb://{db}:{pass}#hostname1.mongodb.net,hostname2.mongodb.net,hostname3.mongodb.net/admin?authSource=admin&replicaSet={replicaSet}&readPreference=primary&ssl=true instead of mongodb+srv:// format
To get the formatted connection string, you can use db.getMongo() command on your cluster

In some causes, for example in environment where you can't change resolver you can use old style URL:
client = pymongo.MongoClient("mongodb://<username>:<password>#<cluster>...
After change URL generated by cloud.mongodb.com Atlas
in section Cluster -> Connect -> Choose a connection method -> Python - 3.4 or later
It finally started working.
My setup:
Ubuntu 18.04
Python 2.7.17 / 2.7.12
Pymongo 3.11.1
Google Cloud SDK 319.0.0

In my case, only MongoDB connections went wrong with my DNS server.
However, it worked with Google DNS 8.8.8.8, as suggested above.
The solution for me was to decrease the UDP max packet size (same as Google DNS)
cat /etc/bind/named.conf.options
options {
#...
listen-on { 127.0.0.1; };
allow-recursion { 127.0.0.1; ::1; };
edns-udp-size 512;
max-udp-size 512;
};

Related

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

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!

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

Why do I get an "message len 1347703880 is invalid. Min 16 Max: 48000000" error when trying to connect to an OKD pod running a simple mongo container?

I have created a Mongo container using only the base mongo:3.6.4 official docker image and deployed it to my OpenShift OKD cluster, but cannot connect to this MongoDB instance using a Mongo client from outside the cluster.
I can access the pod at http://mongodb.my.domain and successfully get the "It looks like you are trying to access MongoDB over HTTP on the native driver port." message.
When using the terminal on the pod I can successfully log-in using:
mongo "mongodb://mongoadmin:pass#localhost" --authenticationDatabase admin
But when trying to connect from outside OKD the connection fails.
My client needs to pass through a proxy before it can access the OKD pods and I do have a .der certificate file but am unsure if this is related to the issue.
Some commands I have tried:
mongo "mongodb://mongoadmin:pass#mongodb.my.domain:80" --authenticationDatabase admin
mongo --ssl "mongodb://mongoadmin:pass#mongodb.my.domain:80" --authenticationDatabase admin
I expected to be able to connect successfully but instead get this error message:
MongoDB shell version v3.4.20
connecting to: mongodb://mongoadmin:pass#mongodb.my.domain:80
2019-05-15T11:32:25.514+0100 I NETWORK [thread1] recv(): message len 1347703880 is invalid. Min 16 Max: 48000000
2019-05-15T11:32:25.514+0100 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host 'mongodb.my.domain:80' :
connect#src/mongo/shell/mongo.js:240:13
#(connect):1:6
exception: connect failed
I am unsure if it an issue with how I am using my MongoDB client or potentially some proxy settings on my OKD cluster. Any help would be appreciated.
The problem here is that external OpenShift routes aren't great at handling database connections. When you attempt to connect to the Mongo pod via the route, the route will accept the connection and transmit your connection to the Mongo service. I believe this transmission wraps the connection in in a HTTP wrapper, which Mongo doesn't like to handle. The OKD documentation highlights that path based route traffic should be HTTP based, which will cause the connection to fail.
You can see evidence of this when trying to connect to a MongoDB database and it returns "It looks like you are trying to access MongoDB over HTTP on the native driver port." to the browser. The user relief.malone explains this and has proposed a couple of solutions / workarounds in their answer to this question.
To add to relief.malone's answer, I would suggest that you port forward from the MongoDB pod to your local machine for development/debugging. In production, you could deploy an application to OKD that references the MongoDB service via it's internal DNS name, which will look something like this: mongodb.project_namespace.svc:27017. This way you will avoid the route interfering with the connection.
The Openshift OKD documentation on port-forwarding isn't that informative, but, since oc runs the kubectl command under the hood, you can read this Kubernetes guide to get some more information

Can't connect Mongo shell to Mongo Atlas M0 using mongodb+srv

I am trying to connect to my MongoDB Atlas Cloud cluster via the mongo+srv connection like so:
mongo "mongodb+srv://cluster0-mhzdc.mongodb.net/test" --username myuser
I am getting this response:
DNSHostNotFound: Failed to look up service "_mongodb._tcp.cluster0-mhzdc.mongodb.net": Undefined error: 0
try 'mongo --help' for more information
I am using the following version of Mongo client:
mongo --version
MongoDB shell version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
I can't find any resolution online. Any ideas what's wrong? Is this a bug in the given version of the Mongo shell client?
It looks like bug 34117, still unresolved:
https://jira.mongodb.org/browse/SERVER-34117
To work around the bug check if you have a DNS resolver active on your notebook.
On windows:
ipconfig /displayDNS
to see the current DNS resolver cache.
You might even try to erase the cache with the command:
ipconfig /flushdns
and retry.
If you are working on linux ubuntu try the command:
named -v
to check if the DNS resolver software is already installed.
If not:
sudo apt update
sudo apt install bind9 bind9utils bind9-doc bind9-host
to install the needed packages, then start the service:
sudo systemctl start bind9
and retry.
On Mac OSX, the command is:
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
The same happens to me, but just after i change my internet provider. Before, i could connect to mongo atlas with no problem.
I guess this happens because the DNS resolver of my internet provider could not resolve the uri to connect to mongodb atlas.
The Solution ->
Change de DNS resolver on my PC:
Open the Control Panel.
Click View network status and tasks
Click Change adapter settings on the left portion of the window.
Double-click the icon for the Internet connection you're using.
Click the Properties button.
Click and highlight Internet Protocol Version 4 (TCP/IPv4) and click Properties.
If not already selected, select the Use the following DNS server addresses option.
Enter the new DNS addresses and click OK and close out of all other windows.
I used google public dns 8.8.8.8.
After that i could connect again with my mongo shell ou compass to mongo atlas.
Hope that helps someone..
I also had this problem with Comcast Xfinity. For those running Ubuntu 18.04 or similar, I had to edit (you'll need root permissions) the /etc/dhcp/dhclient.conf file, and add to following line:
supersede domain-name-servers 8.8.8.8, 8.8.4.4;
I hope this helps somebody, took me too long to figure it out. :-)
I spent lot of time to figure the out issue. after the change DNS it worked. thanks
Used google dns servers.
8.8.8.8
8.8.4.4

nodetool not run when cassandra service is started by java code

I started my CassandraDaemon thread not as service in windows using [services.msc] but by the following code.
public static void start() {
if (cassandraDaemon == null) {
cassandraDaemon = new org.apache.cassandra.thrift.CassandraDaemon();
cassandraDaemon.activate();
}
}
The above code starts the cassandra service and I tested it,it works.But nodetool.bat file not run.
When I use the following command nodetool -h IPADDRESS info it produce
Failed to connect to 'IPADDRESS:7199': Connection refused: connect
as reply.
I added following one during init
System.setProperty("cassandra-foreground","true");
System.setProperty("com.sun.management.jmxremote","true");
System.setProperty("com.sun.management.jmxremote.port","7199");
System.setProperty("com.sun.management.jmxremote.authenticate","false");
System.setProperty("com.sun.management.jmxremote.ssl", "false");**
What should i Add in coding by that nodetool can run....
If any one know kindly reply me as I need it very immediately.....
You are setting the JMX port to 7199, then trying to connect to that using nodetool. Problem is nodetool uses the Thrift port, which by default is 9160.
Ive lost a lot of time trying to fix this, today finally did it
Just go to
C:\Program Files\DataStax Community\apache-cassandra\conf
and edit the file cassandra.yaml
Look for: listen localhost and change it for listen x.x.x.x
where x.x.x.x is the IP of the local host machine.
Restart Cassandra Service and be sure Windows firewall allows the connection.
Maybe you want to start with firewall off to check if nodetool is working.