Connecting to a database
Last updated
Was this helpful?
Last updated
Was this helpful?
For each active database, Tonic Ephemeral provides access to the connection details for the database.
The connection information is on the Connection Details tab of the database details panel.
From the Databases page, to display the connection details for the database:
Click the database icon for the database.
Click the options icon for the database, then click Connection Info.
On the Connection Details tab, each field includes a copy icon to allow you to copy the value to the clipboard.
Note that by default, databases on Ephemeral Cloud are publicly accessible. To limit database access to specific IP addresses, you can configure an allowlist. For more information, go to Configuring an allowlist for Ephemeral Cloud database connections.
For Ephemeral Cloud databases that were created before version 064, you connect to the database through an SSH tunnel.
For these databases, the connection details include the information for the SSH tunnel.
To create an SSH tunnel to a database from a local machine:
ssh -N -L <localport>:<database-hostname>:<database-port> <bastion-username>@<bastion-host> -p <bastion-port>
For example:
ssh -N -L 9999:svc-bd391f5270d64defb63100cc1bdaa32b:5432 jumper@db.ephemeral.tonic.ai -p 9000
In the command:
-N
tells SSH to not open a shell. Ephemeral does not allow shell access.
<localport>
is the port the database will be accessible at on your local machine.
The other values (<database-hostname>
, <database-port>
, <bastion-username>
, <bastion-host>
, <bastion-port>
) are available from the Connection Info panel.
If the private key file is not configured in your SSH agent, then you can optionally add -i
to specify the private key file.
ssh -N -L <localport>:<database-hostname>:<database-port> <bastion-username>@<bastion-host> -p <bastion-port> -i <private-key-file>
For example:
ssh -N -L 9999:svc-bd391f5270d64defb63100cc1bdaa32b:5432 jumper@db.ephemeral.tonic.ai -p 9000 -i ephemeral-key.pem
If you are not sure that the connection is successful, or are unable to connect to the database, then here are a couple of troubleshooting steps to check that the tunnel is open and you can connect to the database.
To verify that the tunnel is open, try to connect in a tool such as telnet or netcat. Test the connection from the same machine that you used when you ran the command to open the tunnel.
For example, to use netcat to try to connect from your local machine:
Or for telnet:
If the tool does not return an error, then the tunnel is open.
After you verify that the tunnel is open, to verify that you can connect to the database, use a terminal client to issue a query against the database.
If the query from the terminal client is successful, but you are unable to connect from your database client, then there might be an issue with your database client.