Skip to content

[Bug]: Session Expires in AdminJS with Node.js Clustering Using express-session #1772

@AsServices

Description

@AsServices

Contact Details

No response

What happened?

When using AdminJS in a Node.js application with the cluster module, logging into the AdminJS panel (/admin) is successful, but after login, its showing alert message "session expired" error and a redirection to /admin/login. This issue occurs only in a clustered environment and not when running a single process.

To Reproduce
Set up a Node.js application with clustering, using @adminjs/express, express-session.
Configure AdminJS with buildAuthenticatedRouter and a MongoDB database adapter.
Start the server with multiple workers (e.g., node run.js).
Access http://localhost:9090/admin, log in with valid credentials.
Observe the "session expired" error and redirection to /admin/login.

Expected Behavior
The session should persist across requests in all cluster workers, allowing uninterrupted access to AdminJS resources after login.

Actual Behavior
After a successful login, navigating to resources or refreshing the page triggers a "session expired" error and a 302 redirect to /admin/login.

Environment
Node.js version: v24
AdminJS version: adminjs@7.8.16
Database adapter: Mongodb/mongoose
Environment: Production (NODE_ENV=production)

Bug prevalence

every time with cluster

AdminJS dependencies version

 "@adminjs/bundler": "^3.0.0",
  "@adminjs/express": "^6.1.1",
  "@adminjs/mongoose": "^4.1.0",
  "@sendgrid/mail": "^8.1.5",
  "adminjs": "^7.8.16",

What browsers do you see the problem on?

No response

Relevant log output

Relevant code that's giving you issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions