MongoLab DB is not responding when using with localhost - node.js

I have an Heroku web applicaiton based on MongoLab MongoDB.
Accessing the site via heroku production site works and I see the site is alive.
My development environment is configured to work with the production DB.When I try to connect I get on:
mongoose.connection.on('error', function(err) {
...
});
And err.message = "connect ETIMEDOUT 54.159.67.179:61188"
How should I continue?

If you click through the resources section of the heroku dashboard and then open your mlab resource it should take you to the mlab home.
The first bit of information should show you how to connect to your database either though the mongo shell or using the standard URI. If you have mongo installed locally can you connect to the remote database this way? If not then it points to network issues. Are you accessing this from behind a corporate proxy? Mongo by default uses port 27017 which isn't open on most corporate proxies. If this is the case then I would speak to your network administrator. I know that at my company we aren't allowed to use this port, but then we don't use cloud infrastructure (yet). Good luck!

I faced the same issue. Solution for me ended up that the environment variable (stored in a .env file in my app) had an old "configvar" (Heroku terminology) and:
go to the desired app Settings tab in Heroku
click the Reveal ConfigVars button
copy the MONGODB_URI value
paste the URI into the .env file (or wherever you store)
That was it, back in business.

Related

MongoDb in Fastcomet shared hosting server

I haven't created an account in fastcomet yet, but I would like to ask the following questions. The site mentions that it supports node.js applications. So that means I can upload an express application right? How about MongoDB and mongoose? I can access MongoDB by typing in the terminal
$ mongod --dbpath=data -bind_ip 127.0.0.1
And the MongoDB URL in my case is
mongodb://localhost:27017/ilovearisti
How different would it be in fastcommet? I guess I'll have to contact them for the port numbers right?
Thanks,
Theo.
FastComet Team here! Indeed, our hosting plans are fully compatible with Node.js apps and you can have your project hosted on an appropriate package.
If you plan using the MongoDB database type in particular, our experience shows it requires a server solution with more resources and a higher level of private access. This way you would be able to accommodate the operation on an environment suitable for coding with Mongoose on top of the MongoDB driver for Node.js.
As for addressing your URL query, the default IP when starting a mongo instance is set to 127.0.0.1, so it is configured as localhost and port 27017. With this in mind, you only need to make changes on the IP configuration via the mongod daemon if you are using a remote database setup with a different IP address.
Having said all of the above, we can confirm that if you have created a database called iloveiristi, the MongoDB URL will be as follows:
mongodb://localhost:27017/iloveiristi
We hope this information proves useful and we wish you good luck with your project.
Best regards!

Changes need to run mongoose on server instead of localhost?

What are the changes I need to run my app on server instead of localhost
mongoose.connect('mongodb://mongoServerIP/dbName)
Since you are running your mongo in your local, you are using localhost. I am not familiar with heroku server, but in general case, you first need to make sure mongo db is running on your heroku server and than you need to put that IP instead of localhost in the above command.
Please refer http://mongoosejs.com/docs/connections.html in case you need login credentials to access the server or any other reference.

database settings in reactioncommerce

I installed reactioncommerce and I would like to access the database settings to check the name that the installation created in my mongodb server. I checked the information on the website but I cannot find any details about it.
in mongodb: when I use "show dbs" in mongo I cannot see any new db in my server. on the other hand, the demo application is running on port localhost:3000.
any guidance appreciated.
well it seems the mongodb for meteor always runs at one port above the meteor port. So by default the db is running at 3001. While you can have Meteor running you can also run meteor mongo and get a db console that way.

Using MongoLab in Heroku doesnt work unless I provide CC number?

I have developed a nodeJS application using Angular as the front-end (used MEAN stack and plan to use Bootstrap with it) and when I try to deploy it to Heroku, whenever I run this line: heroku addons:create mongolab I get the following output:
bruno#bruno-HP-epicsauce:~/herokuFinalApp$ heroku addons:create mongolab
! Please verify your account to install this add-on plan (please enter a credit card) For more information, see https://devcenter.heroku.com/categories/billing Verify now at https://heroku.com/verify
bruno#bruno-HP-epicsauce:~/herokuFinalApp$
And in both sites (mongolab and Heroku) it says it's free... I have already defined the heroku env variable called MONGOLAB_URI, like this:
bruno#bruno-HP-epicsauce:~/herokuFinalApp$ heroku config:set MONGOLAB_URI=mongodb://USER:PASS#ds041643.mongolab.com:41643/dbNAME
Setting config vars and restarting rocky-sea-9859... done, v4
MONGOLAB_URI: mongodb://USER:PASS#ds041643.mongolab.com:41643/dbNAME
bruno#bruno-HP-epicsauce:~/herokuFinalApp$ heroku config | grep MONGOLAB_URIMONGOLAB_URI: mongodb://USER:PASS#ds041643.mongolab.com:41643/dbNAME
bruno#bruno-HP-epicsauce:~/herokuFinalApp$
It still doesnt work...
In the git repository I have the following file structure:
The app is listening on the port: process.env.PORT instead of some local one and the package.json file contains the correct dependencies as it was automatically generated with npm init.
Inside the procfile I have the usual reference to the file that contains my server side code:
web: node server.js
The app.js contains the Angular client-side code.
Is there any 100% free way of deploying an app in Heroku with a DB hosted somewhere?
You have two options to use MongoLab services on Heroku:
Connect to existing MongoLab deployments from Heroku (no credit card required)
Add MongoLab as a Heroku add-on (credit card required)
Since you have set up MONGOLAB_URI, I assume you created a separate account with MongoLab and created a new MongoDB deployment. In this case you don't need an addon. If you have your MongoDB driver configured to use the connection URI, setting MONGOLAB_URI config on Heroku is usually enough.
More info on this here
Heroku asks for a credit card for verification purposes. It won't charge you unless you choose paid addons.
You must verify your account if you want to:
Add any add-on to your app, even if the add-on is free. The only exceptions to this are the free plans for the Heroku Postgres and Heroku Connect add-ons, which can be added without verification (source)
A message from their staff:
You won't be charged if you only use the free plan. Unfortunately some
people use free add-on plans for evil purposes so we need a way to
verify the account. Right now we do that by requesting a valid credit
card, and we may add more verification mechanisms in the future.
I'm in the same point than you, but as you can read, there is no problem to add that information (but to be honest I'd prefer another way as well).
I don't know it will actually charge you, it just wants CC to verify. But you could always just use http://progrium.viewdocs.io/dokku/ or Digital Ocean VPS (which is not actually harder than setting up your dev machine as long as you aren't expecting perfect security etc.).
You do not need mLab MongoDB add-on, just manually add Config Vars

keep separate the local database for local dev and nodejutsu database URL for nodejitsu app?

When I'm developing on my local box I use mongodb://localhost/Data as my connection string when connecting to mongoDB that's running locally.
But then when I upload/update my local app to nodejitsu I have to change the url to the one provided by nodejitsu mongodb://nodejitsu_XXX:xyxyxyxy.mongolab.com:29950/nodejitsu_XXX_nodejitsudb12121212
How do I switch between my localhost mongoDB connection URL and the one provided by Nodejitsu? I don't wanna keep changing it and committing the changes everytime I want to test out my local changes in the cloud...
I use nconf https://github.com/flatiron/nconf , you can easily change between diferent configurations

Resources