Skip to content

Instantly share code, notes, and snippets.

@johnniehard
Last active March 22, 2019 13:58
Show Gist options
  • Save johnniehard/f2ce56c6a3051d8e0341fc73e406c0c3 to your computer and use it in GitHub Desktop.
Save johnniehard/f2ce56c6a3051d8e0341fc73e406c0c3 to your computer and use it in GitHub Desktop.
Port forward to internal ip. Mongo on Dokku

The mongo service need to have exposed ports as per the documentation.

Then, on the Dokku server run

dokku mongo:info <name>

take note of the internal ip of the Mongo server, exposed ports and the Mongo URI.

Then run

ssh -N -L 27017:<INTERNAL_IP>:27017 <USER>@<SERVER>

to create a port forwarding ssh-tunnel to the mongo instance.

Now you can connect to the db as if it was on localhost:27017. Get the password from the Mongo URI.

If using the Mongo URI directly, change the host to localhost, i.e.:

mongodb://<name>:<password>@localhost:27017/<name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment