11 min read

How to Share a Local Database with Your Team Without Deploying It

Share your local PostgreSQL, MySQL, MongoDB, or MSSQL database with teammates using a Localtonet TCP tunnel. Ready in two minutes, no staging environment needed.

🗄️ Database · Team Collaboration · PostgreSQL · MySQL · MongoDB · No Deploy

How to Share a Local Database with Your Team Without Deploying It

Your teammate needs to connect to the database running on your laptop. You have two realistic options: spin up a staging environment and load test data into it, or give them a connection string that points directly at your local instance. The second option takes two minutes instead of two hours. This guide shows how to expose a local PostgreSQL, MySQL, MongoDB, or MSSQL database to anyone on your team using a Localtonet TCP tunnel.

🐘 PostgreSQL 🐬 MySQL / MariaDB 🍃 MongoDB 🪟 MSSQL

Why Share a Local Database Instead of Deploying?

Setting up a staging database means provisioning infrastructure, running migrations, seeding data, keeping it in sync with your local state, and giving teammates access credentials for an environment that might drift from your actual development data within hours. For a quick review session, a bug reproduction, or a short collaborative working session, that overhead is rarely worth it.

Sharing your local database directly is faster and the data is exactly what you are working with right now. Your teammate connects to the same schema, the same seed data, the same state that you are debugging against. No syncing, no migrations to coordinate.

Ready in under two minutes Create a tunnel, share the connection string. No infrastructure to provision, no deployments to trigger.
🔄 Live data, always in sync Your teammate connects to the actual database you are running. Any change you make is immediately visible on their end.
🗑️ Zero cleanup Stop the tunnel when the session is over. No staging environment to tear down, no credentials to rotate.
🔒 Under your control You decide when the tunnel is open and when it is closed. Access disappears the moment you stop it.

How It Works

Database connections use TCP. PostgreSQL listens on port 5432, MySQL on 3306, MongoDB on 27017. These ports are only reachable on your local machine or local network by default. A Localtonet TCP tunnel takes one of these ports and maps it to a public relay address. Your teammate's database client connects to the relay address and the connection is forwarded transparently to your local database. From the client's perspective it is a normal remote database connection.

No changes are needed to your database configuration. No firewall rules to set up. No router port forwarding. The tunnel runs on your machine and makes an outbound connection to the relay, which works even behind CGNAT or a corporate firewall.

PostgreSQL

PostgreSQL listens on port 5432 by default. Before creating the tunnel, make sure PostgreSQL accepts connections from localhost and that you have a user with a password — passwordless peer authentication only works for local socket connections, not for TCP connections that arrive through the tunnel.

Create a database user for the session

psql -U postgres
-- Create a limited user for your teammate
CREATE USER teammate WITH PASSWORD 'strongpassword';
GRANT CONNECT ON DATABASE yourdb TO teammate;
GRANT USAGE ON SCHEMA public TO teammate;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO teammate;

-- If they need write access too
GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO teammate;

Create a TCP tunnel for port 5432

Go to the TCP/UDP tunnel page, select TCP, set local IP to 127.0.0.1 and port to 5432. Click Create and start the tunnel. The dashboard shows a relay address such as example.localto.net:33445.

Share the connection string

postgresql://teammate:strongpassword@example.localto.net:33445/yourdb

Your teammate can connect with psql, DBeaver, TablePlus, or any PostgreSQL client using that string.

Full setup details are in the PostgreSQL documentation.

MySQL and MariaDB

MySQL and MariaDB both listen on port 3306 by default. By default MySQL only allows connections from localhost. You need to create a user that is allowed to connect from any host, since the connection will appear to come from 127.0.0.1 through the tunnel.

Create a user for remote access

-- Connect as root
mysql -u root -p

-- Create user allowed from any host
CREATE USER 'teammate'@'%' IDENTIFIED BY 'strongpassword';
GRANT SELECT ON yourdb.* TO 'teammate'@'%';

-- If they need write access
GRANT SELECT, INSERT, UPDATE, DELETE ON yourdb.* TO 'teammate'@'%';

FLUSH PRIVILEGES;

Create a TCP tunnel for port 3306

Go to the TCP/UDP tunnel page, select TCP, set local IP to 127.0.0.1 and port to 3306. Click Create and start the tunnel.

Share the connection string

mysql://teammate:strongpassword@example.localto.net:33446/yourdb

# Or connect directly with the CLI
mysql -h example.localto.net -P 33446 -u teammate -p yourdb

Full setup details are in the MySQL documentation.

MongoDB

MongoDB listens on port 27017 by default. Recent MongoDB versions require authentication. Make sure you have a user created before sharing access through the tunnel.

Create a database user

// Connect to mongosh
mongosh

// Switch to your database
use yourdb

// Create a read-only user
db.createUser({
  user: "teammate",
  pwd: "strongpassword",
  roles: [{ role: "read", db: "yourdb" }]
})

// Or read-write access
db.createUser({
  user: "teammate",
  pwd: "strongpassword",
  roles: [{ role: "readWrite", db: "yourdb" }]
})

Create a TCP tunnel for port 27017

Go to the TCP/UDP tunnel page, select TCP, set local IP to 127.0.0.1 and port to 27017. Click Create and start the tunnel.

Share the connection string

mongodb://teammate:strongpassword@example.localto.net:33447/yourdb

Your teammate can use MongoDB Compass, mongosh, or any application with a MongoDB driver. Full setup details are in the MongoDB documentation.

Microsoft SQL Server

SQL Server listens on port 1433 by default. Enable TCP/IP in SQL Server Configuration Manager if it is not already on, then create a SQL Server login for your teammate.

Enable TCP/IP and create a login

-- In SQL Server Management Studio or sqlcmd
CREATE LOGIN teammate WITH PASSWORD = 'StrongPassword123!';
USE yourdb;
CREATE USER teammate FOR LOGIN teammate;
GRANT SELECT ON DATABASE::yourdb TO teammate;
-- Add other permissions as needed

Create a TCP tunnel for port 1433

Go to the TCP/UDP tunnel page, select TCP, set local IP to 127.0.0.1 and port to 1433. Click Create and start the tunnel.

Share the connection string

Server=example.localto.net,33448;Database=yourdb;User Id=teammate;Password=StrongPassword123!;

Full setup details are in the MSSQL documentation.

Connecting with GUI Clients

Most database GUI tools accept a host and port separately rather than a full connection string. Use the relay hostname for the host field and the relay port for the port field.

Client Supports Where to enter relay address
DBeaver All databases New connection → Host / Port fields
TablePlus PostgreSQL, MySQL, MongoDB, MSSQL New connection → Host / Port fields
DataGrip All databases Data source settings → Host / Port fields
MongoDB Compass MongoDB Paste connection string or use Advanced Connection Options
pgAdmin PostgreSQL Register server → Connection tab → Host / Port
MySQL Workbench MySQL / MariaDB New connection → Hostname / Port fields
DBeaver
SupportsAll databases
TablePlus
SupportsPostgreSQL, MySQL, MongoDB, MSSQL
MongoDB Compass
SupportsMongoDB
pgAdmin
SupportsPostgreSQL

Security Considerations

👤 Create a dedicated user for each sharing session

Never share your root or admin database credentials. Create a separate user account with only the permissions your teammate actually needs for the session. Grant SELECT only if they are reviewing data. Add INSERT and UPDATE only if they need to write. Drop the user when the session is over.

⏱ Stop the tunnel when the session ends

A database tunnel is for temporary collaboration, not permanent access. Stop it from the Localtonet dashboard or by stopping the Localtonet client when your teammate no longer needs access. The database port becomes unreachable from the internet instantly.

🙈 Use anonymized or seeded test data, not production data

If you are working on a feature and your local database contains real customer records, anonymize sensitive fields before sharing access. Tools like pg_anonymizer for PostgreSQL or a simple seed script can replace real emails, names, and phone numbers with fake equivalents while keeping the schema and relationships intact for testing purposes.

🔑 Use strong passwords for the session user

The relay address is public while the tunnel is running. Anyone who knows the address and port can attempt a connection. A strong password on the database user is the last line of defense. Use a randomly generated password of at least 20 characters for any user you expose through a tunnel.

Frequently Asked Questions

Can my teammate and I both write to the database at the same time?

Yes. Multiple connections to the same database instance are supported by all the databases covered here. Your local client and your teammate's remote client both connect to the same database process. Concurrent writes follow normal database transaction and locking rules, the same as any multi-client database setup.

Will the connection be slow because it goes through a relay?

There is a small latency overhead compared to a direct connection, since traffic travels through the relay server. For interactive use with a GUI client, running queries, and browsing data, this is barely noticeable. For bulk data operations transferring many gigabytes, a direct connection or database dump would be faster. For the collaboration scenarios this guide covers, the relay latency is not a practical problem.

My database is only listening on localhost. Does that need to change?

No. That is the correct and safe default. When you create a Localtonet TCP tunnel with local IP 127.0.0.1 and the database port, the Localtonet client connects to the database on localhost and forwards remote traffic to it. Your database never needs to listen on a network interface. The tunnel handles bridging the connection.

Can I share a database running inside Docker?

Yes. If your Docker container maps the database port to the host, for example -p 5432:5432 or the equivalent in a Compose file then 127.0.0.1:5432 on the host machine reaches the containerized database. Create the Localtonet tunnel pointing at 127.0.0.1:5432 on the host and it works exactly the same way.

How do I delete the session user after the session is over?

Run the appropriate command for your database. For PostgreSQL: DROP USER teammate;. For MySQL: DROP USER 'teammate'@'%';. For MongoDB: db.dropUser("teammate"). For MSSQL: DROP USER teammate; DROP LOGIN teammate;. Stop the tunnel first so no active connections remain, then drop the user.

Can I share multiple databases at the same time?

Yes. Create a separate tunnel for each database port. A single Localtonet client handles all tunnels in your account simultaneously. Each tunnel gets its own relay address and port. Share a different connection string for each database you want to expose.

Share Your Local Database in Under Two Minutes

Create a Localtonet TCP tunnel for your database port, share the connection string, and your teammate is connected to your local instance without a staging environment or deployment.

Create Free Localtonet Account →

Localtonet is a secure multi-protocol tunneling and proxy platform designed to expose localhost, devices, private services, and AI agents to the public internet supporting HTTP/HTTPS tunnels, TCP/UDP forwarding, mobile proxy infrastructure, file server publishing, latency-optimized game connectivity, and developer-ready AI agent endpoint exposure from a single unified control plane.

support