2 months ago
I'm trying to import JSON files into MongoDB using mongoimport, but I keep getting an authentication error even though I've configured MongoDB to run without auth.
Error:
Failed: (Unauthorized) Command insert requires authentication
2026-03-19T21:11:52.036+0200 0 document(s) imported successfully. 0 document(s) failed to import.
Command:
mongoimport --host hopper.proxy.rlwy.net:26641 --db edgar --collection app_settings --file app_settings.json
MongoDB Configuration:
- Image: mongo:8.0
- Start Command:
docker-entrypoint.sh mongod --ipv6 --bind_ip ::,0.0.0.0 --setParameter diagnosticDataCollectionEnabled=false --noauth - Auth Variables: Removed (MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD set to null)
- Volume: Mounted at /data/db (5000 MB)
What I've tried:
- Added
--noauthflag to startCommand - Removed MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD variables
- Redeployed MongoDB multiple times
- Removed and recreated the volume
What's happening: Despite these changes, MongoDB still requires authentication. The deployment appears to complete successfully, but the service still enforces auth.
Question: Why is MongoDB still requiring authentication even with --noauth enabled? Is there something else I need to configure to disable auth on Railway?
2 Replies
Status changed to Awaiting Railway Response Railway • 2 months ago
2 months ago
I have the same problem, but I am using mongorestore. Hope this gets looked at!
Status changed to Open chandrika • 2 months ago
2 months ago
Hello,
your mongodb is still enforcing auth, so just add your credentials to the command:
mongoimport --host hopper.proxy.rlwy.net:26641 --username YOUR_USER --password YOUR_PASS --authenticationDatabase admin --db edgar --collection app_settings --file app_settings.json
check your railway variables tab for the credentials and plug them in; same fix for mongorestore, just add the same three flags
Hope this help you