R
Railway

✋|help

I have problems with the database when I do a deploy.

Jjesussotoweb.link9/18/2023
I have a mongo DB database that is connected to a node js, to connect to mongo I use the url that mongo gives me:

mongodb://mongo:[my-data]@containers-us-west-184.railway.app:5712

the thing is that it creates a database called "test" and not "my data".


already used this form: mongodb://mongo:[my-data]@containers-us-west-184.railway.app:5712/my_db
but it does not work for me

I get this error:

MongoServerError: Authentication failed.

at Connection.onMessage (/app/node_modules/mongodb/lib/cmap/connection.js:202:26)

at MessageStream.<anonymous> (/app/node_modules/mongodb/lib/cmap/connection.js:61:60)

at MessageStream.emit (node:events:513:28)

at processIncomingData (/app/node_modules/mongodb/lib/cmap/message_stream.js:124:16)

at MessageStream._write (/app/node_modules/mongodb/lib/cmap/message_stream.js:33:9)

at writeOrBuffer (node:internal/streams/writable:391:12)

at _write (node:internal/streams/writable:332:10)

at MessageStream.Writable.write (node:internal/streams/writable:336:10)

at Socket.ondata (node:internal/streams/readable:754:22)

at Socket.emit (node:events:513:28) {

ok: 0,

code: 18,

codeName: 'AuthenticationFailed',

connectionGeneration: 0,

[Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }

}

npm WARN config production Use --omit=dev instead.
Mmantisinabox9/18/2023
Please don’t open more than one help thread
Are you using the MONGO_URL reference variable for connecting to your database?
Jjesussotoweb.link9/18/2023
yes i am
Mmantisinabox9/18/2023
Have you changed your reference from “my data” to “test” to see if it will connect and work for you?
Or manually create the database of “my data” or whatever you are trying to call it by clicking the “new database” button?
Mmantisinabox9/18/2023
Jjesussotoweb.link9/18/2023
I already did that in the capture but it doesn't connect me anyway
Jjesussotoweb.link9/18/2023
Mmantisinabox9/18/2023
Hmmm
Jjesussotoweb.link9/18/2023
I'm taking MONGO_URL to connect but it doesn't work
Mmantisinabox9/18/2023
Can you show me your environment variables in your service (app)
Jjesussotoweb.link9/18/2023
In DB_CONECTION there is this url: mongodb://mongo:[my-data]@containers-us-west-184.railway.app:5712
Mmantisinabox9/18/2023
It would be better to use reference variables, simply because if you roll your credentials, they will automatically update for you in your service…
But that’s not the issue here
Jjesussotoweb.link9/18/2023
let me explain, I used this link
mongodb://mongo:[my-data]@containers-us-west-184.railway.app:5712/my_db
when I did this I got the error because with the "/my_db" it would automatically create the database.
using this link without the "/my_db" does work but it does not change the database name, it uses the default "test".
Mmantisinabox9/18/2023
I don’t usually work with Mongo, so, I’m trying to understand everything… without specifying a database name, it will connect to “test” by default, yes. As long as you are calling to the database by the correct name it should work. Are you able to share your repo?
Bbrody1929/18/2023
are you using mongoose?
Mmantisinabox9/18/2023
There’s the guy!
Bbrody1929/18/2023
ive seen this issue before a few times
Jjesussotoweb.link9/18/2023
yes i using mongoose
oh and what is the solution?
Bbrody1929/18/2023
specify the database name with that options parameter
https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.connect()
Bbrody1929/18/2023
but please also use reference variables like vin has said
https://docs.railway.app/develop/variables#reference-variables
once you have setup a MONGO_URL reference variable please show another screenshot of your service variables
Jjesussotoweb.link9/18/2023
ok perfect I'll do it

Looking for more? Join the community!

Recommended Posts
I have problems with the database when I do a deploy.I have a mongo DB database that is connected to a node js, to connect to mongo I use the url that moError comunicate with internal servicecsI'm trying to make a post on a route that is in an internal service on railway = api-ecompleto.railwUnchanged repo fails to deploy on env var change.I had this exact setup running last night, and this morning when I changed an environment variable iIs it possible to host Unity project?I have a unity game development project which runs C# Since I already use railway for my other projCan't see organizations reposTitle.Please my images are not displaying after deploying on railway. I am new in web development.Please I am new to web development and first time deploying to railway. I have django drf backend wiISO 27001Hi this might be a dumb question but does Railway have the ISO 27001 certification or is that irreledeploying react with viteI've deployed a react app with vite, exposing network ip but I can't access it - says Application faOpenSSL error when using Bun + PrismaGetting an error when using Bun and prisma together. Prisma requires node to work, so start command Server isnt workingThe server suddenly stopped working. Could anyone explain what is going on?...How to deploy a project with multiple dockerfiles?Have project that has one `Dockerfile` for the backend service and another one `Dockerfile.celery` fWildcard DNS let user custom there domainI would like to know how to let's my users custom domain with CNAME to my domain DNS my DOMAIN CNABun with turborepo supportHey guys, Just switched over to bun from fastify but having some trouble setting it up properly to How does pro plan upgrade works for application? particularly Spring boot app...Hi all, I find it difficult to understand how pro plan upgrade works. I upgraded my Spring boot app Deploying Rust tries to copy binaries that don't exist.I'm not using my own nixpacks.toml, and railway is attempting to copy binaries that it doesn't need Cron skipingSo my Cron Schedule keeps skipping every time?Request to free up custom domainMy project id : 5df73bd5-7d04-40dd-9e57-97f1cdd89a60 Can u pls delete the given custom domain, it sPR PreviewsHi everyone. Is it possible to setup PR previews with it's own set of environment variables?Looking for way to run LibreTranslate as a service on railwayI'm looking for a way to run https://libretranslate.com on my railway instance. Ideally it would beRTT to nearby datacenter has gone way up in the past few daysRegions have been amazing and are super helpful for our use case. We host our database in AWS us-eas