Mongolab connecting to Heroku with PencilBlue

317 views Asked by At

I have small issue and I don't know where to start: I have application error and I think my MongoLab database is not connecting correctly.

Here is link to heroku w2w.

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

And here is my config.json file:

{
"siteName": "PencilBlue Heroku and MongoDB Demo",
"siteRoot": "http://w2w.herokuapp.com",
"siteIP": "w2w.herokuapp.com",
"log_level": "info",
"db": {
    "type":"mongo",
    "servers": [
    "mongodb://hercules:[email protected]:63330/pencilbluedb"
    ],
    "name": "pencilbluedb",
    "authentication": {
        "un": "hercules",
        "pw": "MYPASSWORD",
    },
    "writeConern": 1
},
"cache": {
    "fake": true,
    "host": "localhost",
    "port": 6379
},
"settings": {
    "use_memory": true,
    "use_cache": false
},
"templates": {
    "use_memory": true,
    "use_cache": false
},
"plugins": {
    "caching": {
        "use_memory": true,
        "use_cache": false
    }
}
} 

I have no idea why it's not loading. I followed the instructions here: Pencilblue link, the only difference is that I'm trying to connect to MongoLab and they are suggesting MongoHQ (which has already been changed to "compose").

Any help would be appreciated.

4

There are 4 answers

2
Blake Callens On

PencilBlue co-founder here.

You're missing the forward slash at the end of the MongoDB URL:

"mongodb://hercules:[email protected]:63330/pencilbluedb/"
3
Will On

Looks like the PencilBlue instructions do not have the db credentials as part of the mongodb connection string. Try leaving those out of the connection string and see if that fixes the problem. Just make sure you specify the credentials in the 'authentication' field which it looks like you are already doing.

0
user2813391 On

It looks like you are defining your DB name twice, once in the URL and once on the "name" attribute. Remove the DB name from the URL. e.g

mongodb://hercules:[email protected]:63330/

instead of

mongodb://hercules:[email protected]:63330/pencilbluedb

And pencilblue should add the DB name when it connects.

0
Dr. Div On

I found this to work:

Say for instance this is your connection string URI

mongodb://heroku_td9xx269:[email protected]:39725/heroku_td9xx269

  "db": {
    "type": "mongo",
    "servers": [
         'mongodb://heroku_td9xx269:[email protected]:39725'
    ],
    "name": "heroku_td9mdp69",
    "authentication": {
        "un": "heroku_td9xx269",
        "pw": "vl3o3hsj6e61ib7kiaul0vsjrd",
    },
    "writeConcern": 1,
    "query_logging": false
},

The trick is to use your dbuser as the value to both the keys "un" and "name" fields.