connect-local-db
v1.0.4
Published
Expose your local PostgreSQL database via ngrok for remote access.
Maintainers
Readme
connect-local-db
Expose your local PostgreSQL database to the internet using ngrok, allowing remote access from your hosted apps or tools.
Designed for developers who need remote access to local PostgreSQL databases during development.
🚀 Features
- Simple CLI — connect in under 1 minute
- Secure tunnel via ngrok (TCP)
- Password input is hidden
- Local DB connection is validated before tunnel starts
- Perfect for connecting hosted backend services to your dev database
📦 Installation
Option 1: Use with npx (recommended)
npx connect-local-dbOption 2: Install globally
npm install -g connect-local-db🛠️ Prerequisites
- PostgreSQL must be running locally on your machine.
- You must have an ngrok account and set your auth token:
npx ngrok config add-authtoken <your_ngrok_token>🧪 Usage
Run:
npx connect-local-dbYou'll be prompted to enter:
- PostgreSQL port (default:
5432) - DB user (default:
postgres) - Password (input hidden)
- Database name
If the connection is successful, you’ll get:
✅ Local PostgreSQL connected successfully.
🔗 Ngrok tunnel created: tcp://4.tcp.eu.ngrok.io:14006
✅ You can now connect to your dev DB remotely.🔗 How to Use the Tunnel Info
From the ngrok output like:
tcp://4.tcp.eu.ngrok.io:14006Use:
| Field | Value |
| ------------ | -------------------- |
| Host | 4.tcp.eu.ngrok.io |
| Port | 14006 |
| User | your PostgreSQL user |
| Password | your DB password |
| Database | your DB name |
Make sure to omit the tcp:// when entering host.
💡 Example Use Cases
- Connect your local DB to a remote backend (e.g., hosted on Vercel, Heroku, etc.)
- Enable cloud services or APIs to access your dev data
- Share your dev DB with collaborators
❗ Common Issues
❌ getaddrinfo ENOTFOUND tcp://...
Don't use the full tunnel URL directly. Instead:
- Host:
4.tcp.eu.ngrok.io(withouttcp://) - Port:
14006(or the actual port from your tunnel)
🔐 Security Tips
- Do not use this tool in production.
- Do not share your ngrok tunnel publicly.
- Close the tunnel when done (
Ctrl + Cin the terminal).
🧑💻 Author
Made by Olugbenga Taiwo Contributions welcome!
📄 License
MIT License
