Problem to connect mongo DB replica set from linux, single instance run ok. Using .net core mongo driver - mongodb

I am trying to connect an application in .net core from a linux machine to a mongo replicaset. But I am getting a timeout error.
Unhandled exception. System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector
The replica ips are accessible from this machine, a response is obtained by pinging.
If in linux the connection to mongo is to a single instance of the replica, it works correctly.
This same code in windows connects without problem.

If you are certain IP connectivity works, most likely you have the hostnames wrong. The hostnames used in RS config must work from each client.
See https://github.com/p-mongo/mongodb-faq.

Related

Unable to connect to mongodb on remote server

I have a spring boot application with a mongo database on localhost and everything work fine.
Now i want to deploy my application to my server and the database is on another remote server.
I changed mongod.conf file and uncommented “bindIp: 0.0.0.0 #default value is 127.0.0.1”
In my application.properties file i have this:
“spring.data.mongodb.uri=mongodb://172.16.4.26:27017/jenkinsdb”
When i run my application i get “com.mongodb.MongoSocketOpenException: Exception opening socket” caused by “Caused by: java.net.SocketTimeoutException: connect timed out”
It seems like MongoDB is not accessible over a network there might be several reasons. I have listed some:
MongoDB port 27017 is not open
Firewall is blocking the connection with another machine
You can also try adding the authentication information in your URI like this:
spring.data.mongodb.uri=mongodb://user:secret#mongo1.example.com:12345,mongo2.example.com:23456/test
OR
you can split it over multiple properties
spring.data.mongodb.host=mongoserver.example.com
spring.data.mongodb.port=27017
spring.data.mongodb.database=test
spring.data.mongodb.username=user
spring.data.mongodb.password=secret
If you want to check whether there is a problem with the application or MongoDB you can spin up the free Mongo Atlas instance and try to connect that with your application if that works then there will be surely a connectivity issue with our machine

Connecting to MongoDB hosted on Amazon EC2 (using PyMongo)

I'm having trouble remotely connecting to my MongoDB instance; I've deployed it using the MongoDB AWS Quick Start, and can connect via SSH as per the "Testing" section of the Quick Start guide.
However, when trying to connect remotely (I'm using the PyMongo driver), I run into a pymongo.errors.ServerSelectionTimeoutError: ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:27017: timed out error.
I've tried setting bind_ip to 0.0.0.0 as well as an Elastic IP to the VPC instance that the mongod is running on, but to no avail. In fact, even pinging the EIP leads to a timeout (although pinging the NAT instance doesn't).
With PyMongo I've tried both DNS's, with and without SSL. I can successfully connect to MongoDB on localhost.
These are the security groups for the VPC: AWS security groups
If anyone has a clue on what I might be doing wrong I would greatly appreciate it; I've been struggling with this for over a day now. Thanks!

Trouble Connect Query Router to Config Server in MongoDB Sharding

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.

mongodb could not connect to server

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.

general sql error

I have created an application in delphi and backend is postgres when i run the application i get the following error
general sql error.could not connect to the server;no
connection could be made because the target machine actively refused
it.[127.0.0.1:1:5433 alias resumep
I uninstalled it and installed it again but it didnt work.Even i changed the port number while installing .
I changed the password and installed again but its giving same error
what is the solution to this problem?
The database cluster of a standard PostgreSQL installation is listening on port 5432. (You can, of course, set up additional db clusters on different ports or configure your database cluster to listen on any other port.)
Any particular reason you try 5433? This is probably the cause of your problem.
If no server is listening on port 5433, the connection is simply not possible.