Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:05:11+00:00 2026-06-11T22:05:11+00:00

I am using ExpressJS and Mongoose. var MongoStore = require(‘connect-mongo’)(express); var sessionStore = new

  • 0

I am using ExpressJS and Mongoose.

var MongoStore = require('connect-mongo')(express);
var sessionStore = new MongoStore({db: 'myappsession'});

app.use(express.session({ secret: "myappsecret", store:sessionStore }));

This results in an "MongoError: Error: unauthorized db". I suppose I would need to pass it my log-in credentials. I also have,

var mongoose = require('mongoose');
var db = mongoose.createConnection('<omitted username, password and address>', 'myappsession');

I am guessing connect-mongo needs this information to log into my database to create the session store?

How do I pass connect-mongo the log-in information? Or am I doing this wrongly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:05:12+00:00Added an answer on June 11, 2026 at 10:05 pm

    In my case, since I am already actively using Mongoose, I ended up using a solution for Mongoose.

    1. Install session-mongoose

    https://github.com/donpark/session-mongoose

    2. Use this tutorial as a guide.

    http://mikevalstar.com/Blog/107/Coding_with_Nodejs_Part_31_Mongoose_Sessions

    3. In particular, I had problem with this line of the tutorial.

    url: "mongodb://localhost/mv"
    

    This should be something like,

    url: "username:password@url/testdatabase"
    

    Sessions are then stored in the database named ""testdatabase" in the collection "sessions".

    I hope this answer help someone avoid some frustration. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

newbie. I'm using ExpressJS/Node. Here's my config stuff: var express = require('express'), app =
I'm writing a node.js app using express and mongoose-auth. When I run my app,
I'm looking at this simple to-do app example using express.js+mongoose (on github: https://github.com/dreamerslab/express-todo-example ).
I've got a node.js REST service running on mongoose and express. I'm also using
I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I have a basic expressjs app (using jade), but I am having trouble rendering
I'm using Express.js to create a server to which I can connect using web
I'm using Mongoose to manage a Mongo database. My connection file is quite simple:
I cant for the life of me get mongoose working in my express app.
Using express.js and everyauth with mongoose-auth, how can I create an external authentication route

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.