Databases — PostgreSQL, MySQL, Oracle, SQL Server

How to connect to databases through Teleport. There are two patterns, depending on the engine — and they differ in one important way: who provides your account.

Engines Pattern Your account

PostgreSQL, MySQL

Native Teleport database (tsh db connect)

Created automatically when you connect — always named after your Teleport username, removed again after you log out. No password, no account request needed.

Oracle, SQL Server

Tunneled TCP app (tsh proxy app)

A real database account (username + password) that devops / the DB admins provide — ask through the usual channel before your first connection.

In both cases Teleport handles the network path, your SSO identity, and session audit — no VPN, no shared connection strings.

Oracle and SQL Server can also be reached with no local port at all via VNet — a stable DNS name with the real port (e.g. <app-name>.teleport.better.care:1521). See VNet in the Teleport Connect guide and the per-engine examples below.

1. PostgreSQL and MySQL — native access

1.1. See what you can reach

tsh db ls

If the list is empty, you haven’t been granted database access yet — ask the platform team.

1.2. Connect from the terminal

The one rule to remember: --db-user is always your own Teleport username. You cannot connect as postgres, root, or anyone else — Teleport creates a personal database account for you at session start and removes it when you disconnect.

PostgreSQL (needs psql installed locally):

tsh db connect --db-user=<your-username> --db-name=postgres <database-name>
# e.g.
tsh db connect --db-user=jdoe --db-name=postgres internal-tools-hc-postgres

MySQL (needs the mysql client installed locally):

tsh db connect --db-user=<your-username> <database-name>
# e.g.
tsh db connect --db-user=jdoe internal-tools-hc-percona-mysql

No password prompt appears — your Teleport session is the credential.

1.3. Connect from a GUI client (DataGrip, DBeaver, pgAdmin, …)

Open an authenticated local tunnel, then point the GUI at it:

tsh proxy db --tunnel --db-user=<your-username> --db-name=postgres <database-name>
# prints something like: 127.0.0.1:51292

In the GUI client set host 127.0.0.1, the printed port, your username — and leave the password empty. The tunnel stays open until you stop the command.

In Teleport Connect, the same thing is one click: find the database under Resources, click Connect, and it opens the tunnel and shows the port. Type a port of your choosing into the Port field and it’s saved with the connection — reconnects (and app restarts) reuse it, so your GUI client config keeps working. Screenshots in the Teleport Connect guide.

1.4. Good to know

  • Your auto-created account has the access tier the platform team granted (read-only or read-write). If you can see tables but not change them, that’s your tier — not a bug.

  • Devops admins on PostgreSQL: your session starts read-write on purpose. For admin work (CREATE ROLE, CREATE DATABASE, DDL, grants) elevate explicitly first — sudo-style:

    SET ROLE teleport_dba;
    -- admin statements here
    RESET ROLE;

    ERROR: permission denied to create role in a fresh session just means you haven’t elevated yet. (On MySQL the admin role is already active at login — no elevation step.)

  • Anything you create in the database (tables, etc.) survives; only your account is cleaned up after the session.

  • ERROR: access to db denied usually means you passed a --db-user other than your own username, or you haven’t been granted this database. Check with the platform team.

2. Oracle — tunneled app

Oracle is reached as a TCP app, not a native Teleport database. Teleport authenticates you and tunnels the connection; Oracle still asks for its own username and password.

Accounts are provided by devops / the DB admins. There is no self-service account on Oracle — request one through the usual channel before your first connection.

tsh apps ls                                  # should list oracle-dev-hc (type TCP)
tsh proxy app oracle-dev-hc --port 11521     # keep this running

Then, in another terminal or your GUI client, connect with the account you were given:

sqlplus <user>/<password>@//localhost:11521/ORCLCDB

SQL Developer / DBeaver: host localhost, port 11521, service name ORCLCDB, plus the provided username and password.

In Teleport Connect: find the app under Resources and use the menu next to Connect → Connect without VNet — it opens the tunnel and shows the local port to use instead of 11521. Set the Local Port field to a fixed value once and it’s saved; reconnect from the connections list (plug icon) to reuse it — clicking Connect on the resource card again picks a new random port. Screenshots and details in the Teleport Connect guide.

2.1. No local port: VNet

With VNet running, skip the tunnel and port entirely — connect to the app’s Teleport address on the real Oracle port:

sqlplus <user>/<password>@//<app-name>.teleport.better.care:1521/<service>

SQL Developer / DBeaver: host <app-name>.teleport.better.care, port 1521, plus the provided account. Works only while VNet is running. (The port is a formality — VNet routes any port on the app’s address to the port from the app definition; see the VNet section for details.)

3. SQL Server (MSSQL) — tunneled app

Same pattern as Oracle: a TCP app tunnel, with SQL Server’s own login on top.

Accounts are provided by devops / the DB admins. SQL logins are not self-service — request one through the usual channel before your first connection.

tsh apps ls                                  # should list mssql-dev-hc (type TCP)
tsh proxy app mssql-dev-hc --port 11433      # keep this running

Then connect with the account you were given:

sqlcmd -S localhost,11433 -U <user> -P '<password>'
sqlcmd separates host and port with a comma (localhost,11433), not a colon — with a colon it silently tries the default port and fails.

Azure Data Studio / SSMS / DBeaver: server localhost, port 11433, SQL login with the provided username and password.

In Teleport Connect: same flow as Oracle — menu next to Connect → Connect without VNet, pin the Local Port once, and reconnect from the connections list to keep it.

3.1. No local port: VNet

With VNet running, connect straight to the app’s Teleport address on the real port (note `sqlcmd’s comma):

sqlcmd -S <app-name>.teleport.better.care,1433 -U <user> -P '<password>'

4. Troubleshooting

Symptom What it means

tsh db ls / tsh apps ls is empty

You haven’t been granted access yet — ask the platform team.

access to db denied on connect

Wrong --db-user (must be your Teleport username) — or no grant for this database.

Password prompt on a PostgreSQL/MySQL connect

You’re not going through Teleport (wrong host/port in the GUI client) — use the tunnel’s 127.0.0.1:<port>.

Oracle/MSSQL login rejected

That’s the database’s own account check — verify the username/password you were given with devops / the DB admins.

Tunnel port stops working

The tsh proxy …​ command was stopped or your cert expired — re-run it (after tsh login if needed).

TCP app port changed after reconnecting in Teleport Connect

You reconnected via the resource card’s Connect button — that starts a new tunnel on a random port. Reconnect from the connections list (plug icon) to reuse your saved port.

<app-name>.teleport.better.care doesn’t resolve

VNet isn’t running — start it from the connections panel in Teleport Connect.

teleport.better.care itself stops resolving (macOS)

Stale VNet DNS overrides after a crash — sudo rm /etc/resolver/*, sudo rmdir /etc/resolver, restart VNet. See VNet troubleshooting.