Skip to main content
All CollectionsDatabase connection guides
How to connect a local database via Ngrok
How to connect a local database via Ngrok
Nick avatar
Written by Nick
Updated over a year ago

Ngrok is a tunneling service that allows you to expose your local server or database to the internet securely. This can be useful for testing and sharing your local database with others.

1. Download and Install Ngrok

Visit the Ngrok website and sign up for an account if you don't have one.

Download the Ngrok command-line tool for your operating system.

2. Setup Your Local Database

Make sure your local database server is up and running. This might be MySQL, PostgreSQL, MS SQL or Oracle database server that you want to expose.

3. Use Ngrok to Expose Your Local Database

Open a terminal (for MacOS or Linux) or command prompt (for Windows) on your computer.

Navigate to the directory where you downloaded the Ngrok executable.

Run the following command to expose your local database:

ngrok tcp [port]

Replace [port] with the port number on which your local database server is running. For example, MySQL is running on port 3306:

ngrok tcp 3306

Ngrok will generate a public URL that can be used to access your local database securely. Look for a line in the terminal that starts with "Forwarding" and provides a public URL:

4. Paste the Database Host and Database Port into the Hostname and Port fields accordingly:

Optional:

When you're done using Ngrok to expose your local database, you can stop the Ngrok process by pressing Ctrl+C (Cmd+C) in the terminal.

Keep in mind that the public URL Ngrok provides is temporary and may change each time you restart Ngrok or your computer.

Connecting your local database via Ngrok can be a convenient way to share it with others for development or testing purposes. However, always exercise caution and ensure you secure your database and Ngrok setup properly, especially when working with sensitive data.

Did this answer your question?