I'm trying to connect my app to MongoDB using MONGO_URL: in MUP. The database is on an independent VPS. The VPS is behind a firewall and is connected to the app VPS via a private network. If I don't secure the database with a username and password I can get it to connect however if I create a user to allow readWrite commands to add security it wont connect. I get this error.
MongoError: failed to connect to server [private-network-ip:27017]
If I log into the database and use show dbs this is what appears:
admin 0.000GB
myspecial_db 0.000GB
local 0.000GB
I'm trying to access the myspecial_db.
MONGO_URL: mongodb://username:password@private-network-ip:27017/myspecial_db
What am I missing here?
It sounds like you can connect to the server ok, meaning that access through the firewall is set up properly.
It is likely that authentication happens on the admin database, in which case you will need to add this to the end of your url:
?authSource=adminYou can also try
?authSource=myspecial_dbIf security is your concern, I would also want to connect using SSL by adding this as well:
&ssl=trueThis will ensure that your username/password is not sent in clear text, as well as encrypting all your data in transmission