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 [] on first connect [MongoNetworkError: connection 5 to 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


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>

Leave a Reply