1
votes

I've recently setup an ec-2 instance to deploy a meteor application on AWS. My app works correctly with mongoDB database.

Now I want to connect my meteor project's database to the EC2 database and then I've tried some command lines :

  • start my meteor project with a new mongo url with the following command line : "MONGO_URL="mongodb://username:[email protected]:27017/Tasks" meteor" but it returns the following screen

  • connect to mongo with the other following command line : "meteor mongo --url xx.xx.xxx.xxx:27017" but it returns a timeout. I thought it was due to the lack of username and password however when I add this option meteor does not assume the command.

  • connect to mongo in my js collection file with "export const Tasks = mongoose.connect("mongodb://username:[email protected]:27017/Tasks").connection;" but it returns "Error: connect ECONNREFUSED" (second screen)

Is there any tips to manage to establish database connection from local meteor ?

Thank you for answer,

Martin

1
I'm curious about the mongoose.connect line, are you using mongoose?corvid
I have import mongoose through le line "var mongoose = require('mongoose');". Is this you're asking for ?Bram'in
you're using mongoose with meteor? Seems a bit unusualcorvid
I've tried different ways, this one is for me the worst but I notify it. Do you know an other way ?Bram'in

1 Answers

0
votes

If the database and the Meteor processes are in the same machine, you can call it from "localhost".

MONGO_URL="mongodb://user:password@localhost/Tasks"

If you really want to use the IP + Port approach, you have to ensure that it's accessible from the EC2 Security Groups you're using.

The same applies for connecting manually in Mongoose but you should't be using Mongoose with Meteor, it has it's own way of handling collections. If you need something more powerful, or a way to extend it yourself checkout the Meteor Simple Schema project.