BUG: MongoDB srv connections dont work with SSH tunnel
Describe the bug If you use a mongodb+srv:// database URL with a ssh tunnel. It will not use the ssh tunnel / the connection won't work due to an error saying that the connection can not have a port
MongoParseError: mongodb+srv URI cannot have port number
at new l (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\plugins\dbgate-plugin-mongo\dist\backend.js:2:219887)
at t.parseOptions (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\plugins\dbgate-plugin-mongo\dist\backend.js:2:488879)
at new w (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\plugins\dbgate-plugin-mongo\dist\backend.js:2:578087)
at Object.connect (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\plugins\dbgate-plugin-mongo\dist\backend.js:2:768701)
at e.exports (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\api\dist\bundle.js:2:2217724)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async process.<anonymous> (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\api\dist\bundle.js:2:2170694)
To Reproduce Steps to reproduce the behavior:
- Create a connection
- change the connection type to mongodb
- click use database URL
- paste a mongodb+srv:// URL into the database url
- click on ssh tunnel
- Add host details.
- SSH authentication I used is key file with a valid key
Expected behavior Should connection to the ssh tunnel then connection to the mongodb
Version Information (please complete the following information):
- OS: Windows 11
- App Version 5.5.5
- Install source Installer
- Type - Application
- Database engine: MongoDb
I tested it and it worked for me
What is your database URL?
I tsetd it with: mongodb://dbusr:dbpwd@localhost:27017/dbname
I tested it and it worked for me
What is your database URL?
I tsetd it with: mongodb://dbusr:dbpwd@localhost:27017/dbname
Hey @janproch , Thank you for your time.
It has to be one hosted on mongo cloud they let you host a free database https://www.mongodb.com/
The URL looks something like the below one. mongodb+srv://user:[email protected]/?retryWrites=true&w=majority
Self hosted instance of mongo work with ssh tunnels it is specifically srv ones that don't
Kind Regards, Nick
Hey, This is still happening for me on Version: 6.3.0 Build date: 2025-03-18
MongoParseError: mongodb+srv URI cannot have port number
at new ConnectionString (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\node_modules\mongodb\node_modules\mongodb-connection-string-url\lib\index.js:146:23)
at parseOptions (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\node_modules\mongodb\lib\connection_string.js:203:17)
at new MongoClient (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\node_modules\mongodb\lib\mongo_client.js:52:61)
at Object.connect (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\plugins\dbgate-plugin-mongo\dist\backend.js:2:96332)
at connectUtility (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\api\dist\bundle.js:2:1529807)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async process.<anonymous> (C:\Users\nick\AppData\Local\Programs\dbgate\resources\app.asar\packages\api\dist\bundle.js:2:1475398)
Error JSON: {}
Connection: {
"engine": "mongo@dbgate-plugin-mongo",
"useDatabaseUrl": "***",
"databaseUrl": "***",
"displayName": "***",
"connectionColor": "***",
"unsaved": false,
"_id": "***",
"parent": "***",
"useSshTunnel": true,
"sshHost": "***",
"sshMode": "keyFile",
"sshLogin": "***",
"sshKeyfile": "***",
"requestDbList": false
}
Regards, nick
@janproch could this be reopened if possible?