Remotely connecting to MongoDB http interface on EC2 server

后端 未结 4 611
一个人的身影
一个人的身影 2020-12-15 10:46

I cannot connect remotely to my mongodb http interface on my AWS ec2 server.

I\'ve checked the log and verified that it\'s listening on port 28017. I\'ve verified w

4条回答
  •  伪装坚强ぢ
    2020-12-15 11:34

    I had a similar problem trying to access the mongo shell remotely, and several of these answers helped with parts of the solution. To summarize:

    • Public IP/DNS: Select your instance on the EC2 Management Console and make sure it has a Public IP or Public DNS. AWS is moving more of the defaults to live within a Virtual Private Cloud (VPC), and it's possible to launch into one with only a Private IP address (internal to the VPC). If you don't have a Public DNS or IP, you need to allocate an Elastic IP.

    • Security Group ports: Again looking at instance details on the EC2 Console, find the Security Groups and select "View Rules". Assuming you're using default Mongo ports, you should have 27017 and 28017 open for TCP from 0.0.0.0/0 or (more secure) from your IP address. If not, select a Security Group for your instance and from the console go to Inbound > Edit > Add Rule > Custom TCP Rule, Port Range: 27017, and an appropriate IP Source. For http interface, add another rule for Port Range: 28017.

    • /etc/mongod.conf:

      • Uncomment port=27017 to make sure you have the default port (I don't think this is actually necessary, but it made me feel better and it's good to know where to change the default port...)
      • Comment out bind_ip=127.0.0.1 in order to listen to external interfaces (e.g. remote connections)
      • Uncomment httpinterface=true if you want to use the http interface
    • Create User: You need to create an admin and/or user to access the database remotely.

提交回复
热议问题