"Connect failed" when trying to connect to the DocumentDB cluster from AWS C9

0

In order to insert data to a cluster with a python script, I try to connect to my cluster DocumentDB on AWS from AWS C9 with this tutorial. But every time I try to connect I get connection failed after 6 attempts:

    (scr_env) me:~/environment/sephora $ mongo --ssl --host xxxxxxxxxxxxx:xxxxx --sslCAFile rds-combined-ca-bundle.pem --username username --password mypassword
    MongoDB shell version v3.6.3
    connecting to: mongodb://xxxxxxxxxxxxx:xxxxx/
    2022-03-22T23:12:38.725+0000 W NETWORK  [thread1] Failed to connect to xxx.xx.xx.xxx:xxxxx after 5000ms milliseconds, giving up.
    2022-03-22T23:12:38.726+0000 E QUERY    [thread1] Error: couldn't connect to server xxxxxxxxxxxxx:xxxxx, connection attempt failed :
    connect@src/mongo/shell/mongo.js:251:13
    @(connect):1:6
    exception: connect failed

I tried to remove the lock file to repair the instance as they do in this answer:

    (scr_env) me:~/environment/sephora $ sudo rm /var/lib/mongodb/mongod.lock
    rm: cannot remove '/var/lib/mongodb/mongod.lock': No such file or directory

I know that the "fail to connect" error can be caused by a lot of reasons, but usually they are:

  • the service (mongo) might not be running on the destination server;
  • the service (mongo) might be listening on a different port number;
  • the service (mongo) might be protected by a firewall somewhere on the destination.

So how can I ensure that:

  • mongo is running on the destination host?
  • mongo is listening on the defined port?
  • I've allowed to connect to the destination host on the defined port from the IP address or network range you're running the command to connect?
demandé il y a 2 ans1489 vues
1 réponse
1

Hi. Make sure the Cloud9 instance is in the same VPC as Amazon DocumentDB cluster. Then double check the security group attached with DocumentDB, it should have an inbound rule to allow connections with source the C9 security group. I recommend following the getting started guide from the DocumentDB documentation.

AWS
Mihai A
répondu il y a 2 ans
  • Thank you very much for your reference @Mihai yet I struggle with installing the mongo shell in my AWS Cloud9.

    Indeed, it seems I can't create the repository file with the echo -e "[mongodb-org-4.0] \nname=MongoDB Repository\nbaseurl=... it returns: mongodb-org-4.0.repo: No such file or directory

    Furthermore, when I tried to install the mongo shell with sudo yum install -y mongodb-org-shell which I didn't had, and which I installed, it returns repolist: 0

  • What's the full 'echo' command you're running ?

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions