0

This is the first time using aws and linux.

I have setup a webserver with export MONGO_URL=mongodb://localhost:27017/app and its works but when I separate my mongodb into another aws instance and changed the localhost to my mongodb instance private ip address its doesnt works anymore.

I use telnet private-ip-add 27017 from webserver and it shows Connection refused

I have also set security group inbound on mongodb instance

Custom TCP Rule TCP 27017 webserver-private-ip-add/31

Can anyone help me? Thanks!

1 Answer 1

1
  1. Double-check the Security Group: Like you said, the EC2 instance must allow incoming TCP connections on port 27017 from either

    • the private IP network address other EC2 instance (e.g. 10.0.0.90/32),
    • or better, the ID of the Security Group, that belongs to the other (accessing) EC2 instance (e.g. sg-0d91740cb).
  2. Double-check the MongoDB config file: Option net.bindIp must not be set to 127.0.0.1 but the local IP of your MongoDB EC2 instance. You could also bind to "everything" (0.0.0.0), but this might be slightly less secure (e.g. if Security Groups are not set up properly).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.