Reputation: 51
I am having trouble deploying my Node.JS app to Heroku, I know it's the database that is causing the issue but can't work out why. I am led to believe that I need to use Mlab instead of MongoDB Atlas so I have now tried both and neither work. When I deploy and visit the url I get an error. Here are the logs:
2019-04-13T21:42:47.139176+00:00 app[web.1]: operationTime:
2019-04-13T21:42:47.139180+00:00 app[web.1]: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1555191760 },
2019-04-13T21:42:47.139181+00:00 app[web.1]: '$clusterTime':
2019-04-13T21:42:47.139182+00:00 app[web.1]: { clusterTime:
2019-04-13T21:42:47.139183+00:00 app[web.1]: Timestamp { _bsontype: 'Timestamp', low_: 2, high_: 1555191760 },
2019-04-13T21:42:47.139184+00:00 app[web.1]: signature: { hash: [Binary], keyId: [Long] } },
2019-04-13T21:42:47.139185+00:00 app[web.1]: name: 'MongoError',
2019-04-13T21:42:47.139187+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {} }
2019-04-13T21:42:47.880138+00:00 heroku[web.1]: State changed from starting to up
2019-04-13T21:43:19.726698+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=my-personal-blog16.herokuapp.com request_id=fa43cfdb-4704-4b0d-8de0-5d65604dd98f fwd="92.233.88.145" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
Here is my URI for connecting to the DB:
require('dotenv').config();
const dbpass = process.env.DB_PASS;
const mlabpass = process.env.MLAB_PASS;
module.exports = {
MongoURI:
`mongodb://fishj123:${mlabpass}@ds149885.mlab.com:49885/heroku_26921dvn`,
};
Link to my git repo: https://github.com/fishj123/personal-blog
Would really appreciate any help.
Upvotes: 0
Views: 596
Reputation: 51
For anyone having similar issues - I worked out what was wrong. I hadn't set my Global Variables within Heroku, I hadn't realized that this was necessary.
Setting the variables in Heroku is as easy as going to the Settings tab and then setting the variables under Config Variables.
Upvotes: 3