No suitable servers found using mongoc connection to DataBase

조회 수: 18 (최근 30일)
Gerardo Moreno
Gerardo Moreno 2023년 3월 15일
답변: Piyush Dubey 2023년 5월 30일
I get an error when trying to start a connection to my database in MongoDB. I am using the code from the documentation:
server = "myIP";
port = 27017;
dbname = "myDBName";
conn = mongoc(server,port,dbname,UserName="user",Password="Pass");
The error I get is as follows: Error using database.mongo.connection
[Mongo Driver Error]: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout
calling ismaster on 'myIP:27017'].
Error in mongoc (line 52)
conn = database.mongo.connection(varargin{:});
Error in mongodb (line 4)
conn = mongoc(server,port,dbname);
I have already verified the connection in the MongoDB shell, I also tried to connect through Compass and in both cases I can connect with my credentials. I turned off the firewall and the error still appears, I hope someone can help me.

답변 (1개)

Piyush Dubey
Piyush Dubey 2023년 5월 30일
Hi Gerado,
[Mongo Driver Error] implicates the error is thrown by MongoDB and later sent towards MATLAB. The following documentation will help you troubleshoot different errors in MongoDB and the Database Toolbox Interface:
These will help you figure out the best practices to use the functionalities provided by the Toolbox to connect to MongoDB data base.
Additionally, this link should be helpful to resolve selection timeout errors in MongoDB:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by