I have tried to connect to my mongodb on a server i own via an ssh tunnel via the following apps but nothing will connect:
compass
robomongo
nosqlbooster4mongo
phpstorm inbuilt mongodb java connector
Server and mongo:
Server: ubuntu 18lts
Mongo: latest community version
The Connection URL in all instances is the same (also tried removing the query params) and this url works on the node app:
mongodb://localhost:27017/data-aggregator?retryWrites=true&w=majority
nosqlbooster4mongo's error message is:
But the connection url is 27017 and gets changed to 37903 for some reason
PHPStorm's error message is:
DBMS: Mongo DB Case sensitivity: plain=mixed, delimited=mixed Driver:
MongoDB JDBC Driver (ver. 1.13, JDBC4.2) Effective version: UNKNOWN
(ver. 0.0) Ping: 10 sec, 289 ms (keep-alive query results in error)
Timed out after 10000 ms while waiting to connect. Client view of
cluster state is {type=UNKNOWN, servers=[{address=localhost:42865,
type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketReadException: Exception receiving
message}, caused by {java.net.SocketException: Connection reset}}].
Nothing works but i cannot understand why.
The SSH connection is working as confirmed by nosqlbooster4mongo and phpstorm
But as soon as it then tries to connect to the local mongodb instance it fails. I don't know if this is an issue with the SSH tunnel or the mongo setup. Via a terminal i can connect to mongo no issue, also the node app there can too.
The tunnels are using the same key as i use to connect to the server via terminal without issue which leads me to believe it is mongo but i don't know where to look :/
As the tunnel is established, then this says the server firewalls are not an issue.
I don't know what it is, is there an additional query param for ssh tunnel access?
Solved by #Jack_Woehr on: https://www.mongodb.com/community/forums/t/mongo-5-community-edition-cannot-connect-via-tunnel/151526
The trick was to not use the ssh tunnel from any of the tools listed and just create a the tunnel on the OS.
Related
I have an issue that i'm trying to fix since yesterday.
In fact, i have a a backend that i want to connect to a MongoDB hosted on the cloud, i use Mongoose, i put a connection string mongodb+srv://user:*********#cluster0-****.gcp.mongodb.net/pws. I have whitelisted all ips to connect to the database.
My problem is that when i run npm start, it connect correctly to the database, and when i run a docker-compose (that runs the same commands), i have this error message :
MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
i don't see what can cause this issue.. please help
What I`m suggesting is :
1- Check if MongoDB is installed on your cloud
2- Check if it`s truly running on the port 27017
Compass fails to connect to MongoDb Server although I can see that the connection is accepted in the console and while mongo is set to listen to the right ip and port. (0.0.0.0 27017)
I have setup MongoDb in an LXD container (running on CentOs 7) inside a CentOs 7 server and I have successfully setup port forwarding from the host to the container using the following command:
lxc config device add mycontainer mongoport proxy listen=tcp:0.0.0.0:27017 connect=tcp:0.0.0.0:27017
while running MongoDb without authentication in the container using the command mongod --bind_ip 0.0.0.0 I can see that when Compass tries to make a connection to the server, the connection is actually accepted:
2019-10-16T07:33:51.008+0000 I NETWORK [listener] connection accepted from 127.0.0.1:41674 #1 (1 connection now open)
However, Compass fails to connect as it shows the following message:
Server selection timed out after 10000 ms
I am not running MongoDb with any particular configuration, and since the connection is accepted, what could go possibly wrong and cause this problem? what is the solution?
Update:
I tried disabling SElinux but it seems it has nothing to do with it.
I'm running Ubuntu 14.04 on an AWS EC2 instance with Apache2. This morning I upgraded my Apache2 settings to allow multiple virtual servers following these instructions: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Just now I tried to access my MongoDB instance, but I cannot do it either through the PHP MongoDB driver or through the shell. I get this error when attempting to connect with a PHP MongoClient():
Failed to connect to: localhost:27017: Connection refused'
and I get this error when trying to run the mongo shell:
2015-06-03T19:23:57.307+0000 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-06-03T19:23:57.308+0000 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
Everything was running fine just last night, and I haven't directly modified MongoDB settings. What can I do to fix this? How do Apache2 settings relate to MongoDB? I've been trying to look through the MongoDB docs, but I don't see anything that looks relevant.
You need to setup Security Group for your EC2 instance. And allow Inbound connection for the mongodb port, in your case 27017.
When I went through the logs, I saw a message that there was insufficient room for "journal file." I rebooted my AMI on an EC2 instance with more storage and reinstalled Mongo. That did the trick. I had uploaded a few files to the instance after updating my Apache2 settings, so those few more files must have pushed the instance past what Mongo could tolerate. Too bad the error message wasn't more helpful, but I should have checked the logs sooner. It would also be nice if the logs had a more explicit message.
I'm working on my project to Create a Sharded Cluster in MongoDB using Microsoft Azure Ubuntu 14.01 Virtual Machine.
I'm using 3 config server, 2 query router, and 4 shard server.
I already install MongoDB on all those server with version 2.6.9. Then i set up all of the configs server and they worked, they're listening. But when i started to configure the query router instances, it didn't want to connect to the configs server. Here is the command that i use:
mongos --configdb config0.example.com:27019,config1.example.com:27019,config2.example.com:27019
Here is one of the error message that appear after i run the command.
Couldn't check dbhash on config server [hostname]:27019 :: caused by :: 11002 socket exception [CONNECT_ERROR] server [[hostname]:27019] connection pool error: couldn't connect to server [hostname]:27019 (23.97.57.219), connection attempt failed.
Is there any solution of this problem? Really appreciate your help.
I'm new to MongoDB. I'm trying to connect to my remote mongo database from my work machine( I tried for both mongohq as well as mongolab). I'm getting the error listed below. When I run the same command from my home machine it runs fine and does connect to remove mongo database. I'm not sure what is messed up on my work machine but I'd like to fix it. Thanks for you help.
MongoDB shell version: 2.4.9
connecting to: linus.mongohq.com:10097/mydb
Thu Jan 16 04:16:02.689 Error: couldn't connect to server linus.mongohq.com:10097
at src/mongo/shell/mongo.js:147
exception: connect failed
As per question comments, your mongo shell client can't connect to the mongo instance. Assuming that your internet connectivity is fine, the most common reason for the failure is that the ports are blocked on your network.
Some ISPs automatically block these ports by default as an additional security protection for users that don't need them open. Contact your ISP or network admin, they should be able to help you out.