Connecting to your localhost database

To connect to a database running on your local computer you simply need to map your local database port to an online URL (as can't directly access your localhost otherwise).

This is easy to do using the open-source, free service known as ngrok.


ngrok tcp 5432 # postgres
ngrok tcp 3306 # mysql
ngrok tcp 1433 # sqlserver



To use ngrok to connect your localhost database to (for free), simply follow these steps:

  1. Signup for a free ngrok account (here)
  2. Install ngrok on your localhost (instructions here)
  3. Configure your ngrok installation (find the token here)
    ngrok config add-authtoken <token>
  4. Start the tunnel:
    ngrok tcp <db-port>
  5. You should now see the forwarding address like this
    Forwarding tcp://<server-host>:<server-port> -> localhost:<db-port>
  6. Use the <server-host> and <server-port> values as the Host and Port values when connecting your database in Trevor here.


If you're having trouble making it work, things to check:

  • the example port numbers above are typically correct, but not always.  Check that you are passing the correct <db-port> to ngrok
  • make sure you are passing the <server-host> and <server-port> to Trevor (not your local host and port)

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.