19 days ago
Hi Railway team,
I have an existing MongoDB service with a persistent volume containing important production data.
I changed the MONGO_INITDB_ROOT_PASSWORD environment variable and restarted/redeployed the MongoDB service. However, I later realized that this variable is only used during the initial database creation, so changing it does not update the existing MongoDB root user's password.
The MongoDB instance is still using the original password, but unfortunately I no longer have access to that password. My applications are now failing authentication and I cannot access the database.
I do not have a database backup, so deleting or resetting the volume is NOT an option. The existing volume/data must be preserved.
The MongoDB logs currently show repeated authentication failures (Failed to authenticate).
Could you please help me recover access or reset the MongoDB root user's password without deleting or recreating the persistent volume?
If necessary, I can provide the Project ID, Service ID and deployment details privately.
Please do not reset/delete the MongoDB volume.
Attachments
2 Replies
19 days ago
Having looked into this, the issue appears to be in your application code or configuration rather than the Railway platform itself, which puts it outside what Railway support can resolve directly.
This is exactly the kind of problem the Railway community is good at, so we'd like to open your thread as a community bounty. Railway pays a bounty to the community member who solves it, and threads like this usually get picked up quickly.
Opening it makes this entire thread public, including everything already posted. Nothing becomes public until you decide. Use the buttons below.
- Open to the community - Before you click, take a moment to edit or remove anything you'd rather not share. The thread becomes publicly visible right away.
- Keep it private and close the thread - Nothing becomes public and the thread closes.
Status changed to Awaiting User Response Railway • 19 days ago
19 days ago
This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.
Status changed to Open Railway • 19 days ago
19 days ago
Try this:
- Keep a copy of the current start command of your MongoDB service.
- Change the start command to
mongod --dbpath /data/db --bind_ip 0.0.0.0 --noauthand redeploy. - Go to the Console tab.
- Run
mongosh, thenuse admin, thendb.changeUserPassword("mongo", "<NEW_PW>"), where<NEW_PW>is the desired password. - You should receive
{ ok: 1 }as a response. - Restore the original start command and redeploy.