Hello all,
I can't get the keystone app to work:
Error: Trying to open unclosed connection.
at NativeConnection.Connection.open (/home/bcaspari/keystone/mojorider/node_modules/mongoose/lib/connection.js:236:15)
at Mongoose.connect (/home/bcaspari/keystone/mojorider/node_modules/mongoose/lib/index.js:241:47)
at mount (/home/bcaspari/keystone/mojorider/node_modules/keystone/lib/core/mount.js:611:17)
at start (/home/bcaspari/keystone/mojorider/node_modules/keystone/lib/core/start.js:239:7)
at Object.<anonymous> (/home/bcaspari/keystone/mojorider/keystone.js:118:10)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:134:18)
at node.js:962:3
My keystone.js File:
var express = require('express'),
mongoose = require('mongoose'),
app = express(),
keystone = require('keystone');
keystone.set('app', app);
keystone.set('mongoose', mongoose);
var mongoUri = "mongodb://blabla:blabla@localhost:21103/mojoriderDB";
var options = {
auth: {authdb:"admin"}
}
mongoose.connect(mongoUri, options);
// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.
keystone.init({
'name': 'Mojorider',
'brand': 'Mojorider',
'less': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'jade',
'emails': 'templates/emails',
'auto update': true,
'session': true,
'auth': true,
'user model': 'User',
'cloudinary config': 'blabla',
'cookie secret': 'blabla'
});
I don't use dotenv because it caused trouble and I removed the mongo_URI from the .env file as well.
Anyone an idea why I can't connect?
I'm using keystone on uberspace with node V4.3.2 and mongo 2.6.12
Thanks in adnvance.
Bene
hm,
as no one can reproduce my error I have at least one question:
What is the best way to connect to mongo DB:
I've seen lots of different ways for keystone:
.env file with MONGO_URI string
mongo: option in keystone.init
with mongoose (like in my case)
but nothing seems to work on my side (sometimes keystone still tries to connect to default port mongo instance instead of the one I declared).
So can anyone give me some advice?
-> mongo db is running on server.
I created a new DB and a new admin user.
-> try to connect to db but does not work?
Some kind of best practice?
mongoose.createConnection does also throw errors. Really annoying for me.
So would be really happy for every help I can get!
We're closing all questions and support requests to keep the issue tracker unpolluted. Please ask this question on Stackoverflow or Gitter instead!