简体   繁体   中英

AWS + MongoDB : How to connect to mongo server on AWS linux instance?

I launched an AWS linux instance and installed and ran mongo as instructed here . The mongo service is running and accepting connections on 27017. However, when I go to the server publik dns with port 27017 the server does not respond and I don't see the default mongo message.

I am trying to run a Python(Flask) server on another instance and trying to connect to the mongo server using the private ip, but the connection does not happen. I get this error message on the terminal :

pymongo.errors.ServerSelectionTimeoutError: xxx.xx.xx.xx:27017: [Errno 111] Connection refused

Is this not the right way to use mongo db on aws ? If this approach is feasible, what is causing the connection to not happen ?

All inputs appreciated, much thanks!

It is possible that your mongodb is configured to only accept connection from local host. Edit /etc/mongod.conf file to comment out the line that bindIP like in the example below -

 # network interfaces net: port: 27017 # bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM