Skip to content

Connect to a database

Connect to PostgreSQL, MySQL, ClickHouse, Redis, or any database whose client uses a single TCP connection.

The publisher must reach your database. The caller needs Node.js 26.7 or later, a database client, and valid database credentials. Configure database authentication and TLS for your use case.

PostgreSQL example

On the publisher machine, expose PostgreSQL on its local port:

npx tubu-cli tcp 5432 --domain my-postgres.tubu.dev

After Tunnel ready, run the caller in its own terminal on the client machine:

npx tubu-cli forward 15432 -d my-postgres.tubu.dev

After Listening, connect from another terminal. Replace app and appdb with your database user and database:

psql -h 127.0.0.1 -p 15432 -U app -d appdb

Connection settings and failures

For a remote database target, use a URL such as tcp://db.internal:5432 on the publisher. Do not place database credentials in that URL.

Tubu transports database TLS unchanged. If your client validates the database hostname, preserve its expected server name and certificate settings when connecting through the local listener. Tubu does not replace database authentication.

For connection or port errors, see the FAQ.