Connect with MongoDB on separate EC2 Instance


  • You need to open mongoDB port to world so that you can listen inbound traffic. To do so:
    In instance security group -> Inboud Open 27017 port or whatever port on which your mongoDB is currently running.

    
    Type             Protocol  Port          Range Source
    Custom TCP Rule     TCP       27017         0.0.0.0/0
    OR
    Custom TCP Rule     TCP       mongoDB_port  your_ip/CIDR
    

    Amazon FAQ about CIDR

  • In /etc/mongod.conf which is now default configuration file for mongoDB.
    Change binIP: 127.0.0.1 to 0.0.0.0.
    By default it listen to local host.

    
    # network interfaces
    net:
      port: 27017
      bindIp: 0.0.0.0
    
  • Run this command to reflect changes:

    sudo service mongod restart
Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in amazon, EC2, mongodb, mongoid

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: