question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Error setting TTL index on collection : sessions

See original GitHub issue

Hi, When My App Tries To Connect To The DB I Get This Error:

/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:529
    throw err;
          ^
Error: Error setting TTL index on collection : sessions
at module.exports._get_collection (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/lib/connect-mongo.js:137:23)
at Db.ensureIndex (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1227:28)
at Db.indexInformation (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1371:30)
at Cursor.toArray (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:156:22)
at Cursor.nextObject.self.queryRun (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:611:39)
at Cursor.close (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:939:5)
at Cursor.nextObject.commandHandler (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:611:21)
at Db._executeQueryCommand (/Users/Ari/Dev/ArisGame/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1709:18)
at g (events.js:192:14)
at EventEmitter.emit (events.js:126:20)

I’m Sorry, This Is All I Really Know

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:32 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
htxuankhoacommented, Jun 27, 2015

Hi everyone, I tried to install traider.io in my local machine and I also met this error:

Error: Error setting TTL index on collection : sessions
...

After searched, as I know because the version of connect-mongo & mongodb is not compatible. So, in my case, I re-installed mongodb with this version & it works:

npm install mongodb@1.4.x

Hope this help for someone like me 😃

0reactions
jdesboeufscommented, Aug 29, 2016

Hello,

You should upgrade your connect-mongo version! Le lun. 29 août 2016 à 05:07, my1GitHub notifications@github.com a écrit :

Hi, everyone.this error: connect to mongo success { [MongoError: driver is incompatible with this server version] name: ‘MongoError’ }

E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\base.js:242 throw message; ^ Error: Error setting TTL index on collection : sessions at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\lib\connect-mongo.js:162:23 at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1430:36 at __executeInsertCommand (E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1829:12) at Db._executeInsertCommand (E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1930:5) at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1427:14 at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1560:7 at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:162:16 at commandHandler (E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\cursor.js:706:16) at E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\db.js:1806:9 at Server.Base._callHandler (E:\nodeProject\testProjectEJS\node_modules\connect-mongo\node_modules\mongodb\lib\mongodb\connection\base.js:442:41)

and this is my package “body-parser”: “^1.13.2”, “connect-mongo”: “^0.4.1”, “cookie-parser”: “^1.3.5”, “debug”: “~2.2.0”, “ejs”: “~2.4.1”, “express”: “~4.13.4”, “express-session”: “^1.13.0”, “mongodb”: “^2.2.8”, “morgan”: “~1.7.0”, “serve-favicon”: “~2.3.0” How can i to sovle it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jdesboeufs/connect-mongo/issues/65#issuecomment-243022742, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLJgGDPEkgcG_lL_kQXVN1pRkk70usuks5qkkzTgaJpZM4AlvIe .

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongoDB: Error setting TTL index on collection : sessions
I'm handling my session store with Mongo and as I understand it, the TTL index is used to make the session data expire....
Read more >
Error setting TTL index on collection : sessions · Issue #514 ...
Hi, I've had the error MongoDB: Error setting TTL index on collection : sessions change from // Express/Mongo session storage ...
Read more >
Error setting TTL index on collection : sessions <Error: no open ...
Hi Smita. The first problem should be solved by setting {auto_reconnect : true} for your express sessions store. The second problem is caused...
Read more >
Error setting TTL index on collection : sessions-node.js
The solution is to wait for the connection to occur before allowing your application to start listening.
Read more >
TTL Indexes — MongoDB Manual
A background thread in mongod reads the values in the index and removes expired documents from the collection. When the TTL thread is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found