How to connect pencilblue and mongodb running on two different AWS EC2 instances?

66 Views Asked by At

I have mongodb running on once ec2 instance and pencilblue running on another instance. After installing penciulblue, i've used the command pbctrl start to start the server. Then i get the following error

2016-04-25T20:35:12.100Z - error: [1] System[1]: uncaught Exception detected : Error: MongoError: connect ECONNREFUSED - mongodb://<private IP of mongodb EC2 inatnce>:27017/pencilblue?
Is your instance running?
    at /home/ubuntu/PencilBlue/pencilblue/include/dao/db_manager.js:113:31
    at /home/ubuntu/PencilBlue/pencilblue/node_modules/mongodb/lib/mongo_client.js:267:20
    at /home/ubuntu/PencilBlue/pencilblue/node_modules/mongodb/lib/db.js:218:14
    at null.<anonymous> (/home/ubuntu/PencilBlue/pencilblue/node_modules/mongodb/lib/server.js:226:9)
    at g (events.js:180:16)
    at emit (events.js:98:17)
    at null.<anonymous> (/home/ubuntu/PencilBlue/pencilblue/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:263:68)
    at g (events.js:180:16)
    at emit (events.js:98:17)
    at null.<anonymous> (/home/ubuntu/PencilBlue/pencilblue/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:77:12)

In the config.js file of pencilblue, i've mentioned the db details as follows

"db": {
        "type": "mongo",
        "servers": [
            "mongodb://<private IP of mongodb EC2 inatnce>:27017/"
        ],
        "name": "pencilblue",
        "writeConcern": 1
    }

Thanks in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

Open port 27017 of the security group that your MongoDB server is in, to allow access from the security group that your PencilBlue server is in.

Also make sure you have updated the bind_ip setting in your MongoDB config so that it will listen for connections outside localhost.