Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Solved! Go to Solution.
@Anonymous
What’s the error message you got?
By default, MongoDB is not allowed to remote access, you need to enable remote access by modifying mongod.conf file.
See: MongoDB – Allow remote access
Then to connect to MongoDB via an SSH tunnel, we need to setup the tunnel separately with an SSH client.
For example the mongolite manual contains this example:
con <- mongo("mtcars", url = "mongodb://readwrite:[email protected]:43942/jeroen_test")
Assume we want to tunnel through dev.opencpu.org which runs an SSH server on the standard port 22 with username jeroen. To initiate a tunnel from localhost:9999 to ds043942.mongolab.com:43942 via the ssh server dev.opencpu.org:22, open a terminal and run:
ssh -L 9999:ds043942.mongolab.com:43942 [email protected] -vN -p22
At last, we can connect to our ssh client which tunnel traffic to MongoDB server. In this example we run the ssh client on localhost port 9999:
con <- mongo("mtcars", url = "mongodb://readwrite:test@localhost:9999/jeroen_test")
con$insert(mtcars)
For more information, please check : SSH Tunnel
Regards,
Pirlo Zhang
@Anonymous
What’s the error message you got?
By default, MongoDB is not allowed to remote access, you need to enable remote access by modifying mongod.conf file.
See: MongoDB – Allow remote access
Then to connect to MongoDB via an SSH tunnel, we need to setup the tunnel separately with an SSH client.
For example the mongolite manual contains this example:
con <- mongo("mtcars", url = "mongodb://readwrite:[email protected]:43942/jeroen_test")
Assume we want to tunnel through dev.opencpu.org which runs an SSH server on the standard port 22 with username jeroen. To initiate a tunnel from localhost:9999 to ds043942.mongolab.com:43942 via the ssh server dev.opencpu.org:22, open a terminal and run:
ssh -L 9999:ds043942.mongolab.com:43942 [email protected] -vN -p22
At last, we can connect to our ssh client which tunnel traffic to MongoDB server. In this example we run the ssh client on localhost port 9999:
con <- mongo("mtcars", url = "mongodb://readwrite:test@localhost:9999/jeroen_test")
con$insert(mtcars)
For more information, please check : SSH Tunnel
Regards,
Pirlo Zhang
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 25 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 54 | |
| 46 | |
| 38 | |
| 28 | |
| 21 |