mongodb import
guymalka
HOBBYOP

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:

  1. Added --noauth flag to startCommand
  2. Removed MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD variables
  3. Redeployed MongoDB multiple times
  4. 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?

$10 Bounty

2 Replies

Status changed to Awaiting Railway Response Railway 2 months ago


adrianandersen
PRO

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


domehane
FREE

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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...