So I'm working my way though the Getting Mean book from Manning and following the steps in Chapter 5 I'm trying to use a db on Mongolab as an add-on to Heroku. When I run this code (both locally and on Heroku) it returns this error:
MongoError: getaddrinfo ENOTFOUND undefined undefined:27017
This is my current code:
var mongoose = require('mongoose');
var dbURI = "mongodb://localhost/loc8r";
if (process.env.NODE_ENV === 'production') {
dbURI = process.env.MONGOLAB_URI;
}
mongoose.connect(dbURI);
Troubleshooting I started the app from the terminal with:
NODE_ENV=production MONGOLAB_URI=/*my mongo uri here*/
with that it runs fine locally. So I'm not sure where the issue is coming from. Any suggestions for troubleshooting the error listed?
So I'm not sure what part of this process fixed the issue but I completely removed/deleted the mongolab addon from Heroku. Then I added it back on and performed the same exact steps with the same code and it worked!
Thanks for everyone who was helping out!