Hello
@Splatted_I0I,
Welcome to the MongoDB Community forums ![]()
I ran the following code on my system using node v18.7.0:
import mongoose from "mongoose";
const connect = async () => {
mongoose.connect('mongodb://mongo:<password>@containers-us-west-85.railway.app:6949')
.then(() => console.log('Connected to database movieDB'))
.catch((err) => console.log(err));
}
connect();
Initially, there was an error in the .catch(...) parameter,
which I modified to the above code, and it ran successfully with the output:
[Running] node "/node-mongoDB/src/test.js"
Connected to database movieDB
Although the code seems fine, based on the error message you provided, it may be an incorrect combination of user-id/password or might be an issue with the built-in role. Please double-check the code you are running and the role of your database user, if it still does not work as expected, please provide more details about the error and your workflow.
For more information, please check the documentation on how to manage users and role
Also, please note that you should not share the URI string with the user-id and password on public forums or anywhere else to avoid any potential issues.
I hope this information helps you!
Let me know if you have any further questions.
Best,
Kushagra