Please let me know if you have any questions/comments/feedback. Once you have the SSH tunnel set you can connect via RoboMongo on localhost:6666.Īny traffic will be diverted to 1.2.3.4 then to localhost:27017. Please make sure not to use low port numbers (lower than 1024) as local machine's port, since you won’t be able to bind them without root privileges. The -i parameter allows you to connect using a. And 1.2.3.4 is remote server's ip address. For installing from source, clone the repo and run: python setup.py install Testing the package In order to run the tests you first need tox and run: python setup. In this python mongodb tutorial, we will create a shopping list and add a few. sshtunnel is on PyPI, so simply run: pip install sshtunnel or easyinstall sshtunnel or conda install -c conda-forge sshtunnel to have it installed in your environment. The userId is the userId you use to login to remote box. 27017 ,27017 by default port of mongodb and accesing my remote db which is. Ssh -fN -i ~/.ssh/YourKeyFile.pem -L 6666:localhost:27017 command above is setting up: traffic on your local machine's 6666 port to be forwarded to remote server's localhost:27017. Issue the following command on your terminal (I am using Mac hence a UNIX based system): Being able to use RoboMongo is a major productivity boost and I want to be able to use it to connect to remote DB. Then, in another terminal window, run the 'mongo' shell from your local computer. Of course manually typing in my queries on a command line isn't my favorite thing to do. 1 First make sure you have no local MongoDB running on your machine, then ssh to the server where MongoDB is running: ssh -L 27017:MYHOST:27017 MYUSERMYHOST Replace MYUSER and MYHOST with your username and host. Which means logging into the box, using mongo command to connect to the database and then issue my queries. In my case the problem is that the MongoDb server is on a private network and the only way to get to the private server from my machine is via ssh. After the MongoDB credentials page opens, change the Encrypted toggle to Yes. Go to Data > Connections and click Add New Data Source. The next section walks you through creating the user and import the keys. # Rest of file contains routes with calls to databaseĭoes anyone know why I am getting these errors? Thanks.I love to use RoboMongo as the Mongo DB Query tool. The public key is used to authorize the Commerce Intelligence Linux user. And it's not a problem with the URI since I can log into a Mongo shell with it when the SSH connection is up.Īpp.config = os.environĪpp.config = Trueĭatabase.py from flask_pymongo import PyMongoįrontend = Blueprint('frontend', _name_) This leads me to believe that I am missing a step when connecting to the remote MongoDB. One last thing: I have not experienced any errors when trying to connect to the local MongoDB running in a local Docker container. (The previous error only happens when the local container is not running). This only happens if I have a Docker container with Mongo running on my local machine. : 127.0.0.1:9999: Connection refused, Timeout: 30s, Topology Description: ]>Īnother error I've been seeing is PyMongo authentication failed. PyMongo cannot seem to connect to the database (connection refused). The issue is when I try to run the Flask app. My Mongo URI is I tunnel the SSH connection to the server: ssh -L 9999:localhost:27017 -N I connect to a Mongo shell after tunneling the connection, it works as expected. The data that I need is from MongoDB, which is running on a Docker container on a server.
0 Comments
Leave a Reply. |