Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see public ip address of elastic beanstalk instance for whitelisting mongodb atlas

I am trying to connect to a database hosted on mongo atlas from a service running on elastic beanstalk. I am getting the error:

UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [youmaylike-shard-00-01-necsu.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to youmaylike-shard-00-01-necsu.mongodb.net:27017 closed]

I believe this is happening because I don't have the Ip address of my service whitelisted on atlas. I am unsure of how to get the Ip address for my service, I tried running eb ssh but I'm not sure what it gave me is the correct value

like image 551
user9650710 Avatar asked Sep 09 '19 04:09

user9650710


People also ask

How do I find my Mongodb IP address?

To find the public IP address for any node in your cluster, use the nslookup tool from the command line. The IP address is shown in the Address portion of the output.

How do I access Elastic Beanstalk instance?

Right-click the instance ID for the Amazon EC2 instance running in your environment's load balancer, and then select Connect from the context menu. Make a note of the instance's public DNS address on the Description tab. Connect to an instance running Linux by using the SSH client of your choice, and then type ssh -i .

What is my Elastic IP address?

An Elastic IP address is a reserved public IP address that you can assign to any EC2 instance in a particular region, until you choose to release it. To allocate an Elastic IP address to your account in a particular Region, see Allocate an Elastic IP address.


1 Answers

There are multiple ways to get it, below two:

Before using the AWS console or the AWS CLI run eb health and get the intance ID or IDs for your deployment

  1. Using the AWS Console go to EC2 and then Instances find the instance ID or IDs click it and on the pane below the IP will be located at "IPv4 Public IP"

  2. Using the AWS CLI aws ec2 describe-instances --instance-ids <YOUR INSTANCE ID or IDS HERE>

like image 153
Everton Yoshitani Avatar answered Oct 23 '22 05:10

Everton Yoshitani