# Connecting with psql
This guide explains how to connect to a **TimescaleDB** database using the **`psql`** command-line tool. It walks through the necessary setup, connection process, and execution of a simple SQL query.
### **Variables**
To connect to a TimescaleDB database, you only need **one environment variable** — the connection URI.
**Variable**
| **Description**
| **Purpose**
|
---|
`TIMESCALE_URI`
| Full TimescaleDB connection string from Elestio
| Encodes all connection info in one URI
|
A typical URI looks like this:
```bash
postgresql://:@:/
```
You can find the details needed in the URI from the **Elestio service overview** details. Copy and replace the variables carefully in the URI example provided above.
[](https://docs.elest.io/uploads/images/gallery/2025-05/NKlscreenshot-2025-05-13-at-12-30-16-pm.jpg)
### **Prerequisites**
While following this tutorial, you will need to have **`psql`** already installed; if not head over to [https://www.postgresql.org/download/](https://www.postgresql.org/download/) and download it first.
### **Connecting to TimescaleDB**
Open your terminal and run the following command to connect to your TimescaleDB database using the full connection URI:
```
psql TIMESCALE_URI
```
If the connection is successful, you’ll see output similar to this. Here it will show you the database you tried to connect to, which in this case is Elestio:
```bash
psql (17.4, server 14.13 (Debian 14.13-1.pgdg120+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off, ALPN: none)
Type "help" for help.
elestio=#
```
To ensure you're connected correctly, run this command inside the `psql` prompt:
```postgresql
SELECT version();
```
You should receive output like the following:
```postgresql
version
---------------------------------------------------------------------------------------------------------------------
PostgreSQL 16.8 (Debian 16.8-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)
```