Install self-hosted TimescaleDB on Debian-based systems

You can host TimescaleDB yourself, on your Debian or Ubuntu system. These instructions use the apt package manager on these distributions:

  • Debian 9 Stretch
  • Debian 10 Buster
  • Debian 11 Bullseye
  • Ubuntu 18.04 LTS Bionic Beaver
  • Ubuntu 20.04 LTS Focal Fossa
  • Ubuntu 22.04 LTS Jammy Jellyfish


If you have already installed PostgreSQL using a method other than the apt package manager, you could encounter errors following these instructions. It is safest to remove any existing PostgreSQL installations before you begin. If you want to keep your current PostgreSQL installation, do not install TimescaleDB using this method. Install from source instead.

Installing self-hosted TimescaleDB on Debian-based systems

  1. At the command prompt, as root, add the PostgreSQL third party repository to get the latest PostgreSQL packages:

    apt install gnupg postgresql-common apt-transport-https lsb-release wget
  2. Run the PostgreSQL repository setup script:

  3. Add the TimescaleDB third party repository:

  4. Install Timescale GPG key

    wget --quiet -O - | sudo apt-key add -


    For Ubuntu 21.10 and later use this command to install Timescale GPG key wget --quiet -O - | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg

  5. Update your local repository list:

    apt update
  6. Install TimescaleDB:

    apt install timescaledb-2-postgresql-14


    If you want to install a specific version of TimescaleDB, instead of the most recent, you can specify the version like this: apt-get install timescaledb-2-postgresql-12='2.6.0*' timescaledb-2-loader-postgresql-12='2.6.0*'

    You can see the full list of TimescaleDB releases by visiting our releases page. Note that older versions of TimescaleDB don't always support all the OS versions listed above.

When you have completed the installation, you need to configure your database so that you can use it. The easiest way to do this is to run the timescaledb-tune script, which is included with the timescaledb-tools package. Run the timescaledb-tune script using the sudo timescaledb-tune command. For more information, see the configuration section.

Set up the TimescaleDB extension

When you have PostgreSQL and TimescaleDB installed, you can connect to it from your local system using the psql command-line utility.

Install psql on Debian and Ubuntu

You can use the apt package manager on Debian and Ubuntu systems to install the psql tool.

Installing psql using the apt package manager

  1. Make sure your apt repository is up to date:
    apt-get update
  2. Install the postgresql-client package:
    apt-get install postgresql-client

Setting up the TimescaleDB extension

Restart PostgreSQL and create the TimescaleDB extension:

  1. Restart the service after enabling TimescaleDB with timescaledb-tune:

    systemctl restart postgresql
  2. On your local system, at the command prompt, connect to the PostgreSQL instance as the postgres superuser:

    -u postgres psql

    If your connection is successful, you'll see a message like this, followed by the psql prompt:

    psql (15.0 (Ubuntu 15.0-1.pgdg20.04+1), server 14.5 (Ubuntu 14.5-2.pgdg20.04+2))
    SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
    Type "help" for help.
  3. Set the password for the postgres user:

    \password postgres
  4. Exit from PostgreSQL:

  5. Use psql client to connect to PostgreSQL:

    psql -U postgres -h localhost
  6. At the psql prompt, create an empty database. Our database is called tsdb:

    CREATE database tsdb;
  7. Connect to the database you created:

    \c tsdb
  8. Add the TimescaleDB extension:

  9. Check that the TimescaleDB extension is installed by using the \dx command at the psql prompt. Output is similar to:

    tsdb-# \dx
    List of installed extensions
    Name | Version | Schema | Description
    plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
    timescaledb | 2.7.0 | public | Enables scalable inserts and complex queries for time-series data
    (2 rows)

After you have created the extension and the database, you can connect to your database directly using this command:

psql -U postgres -h localhost -d tsdb

Where to next

Now that you have your first TimescaleDB database up and running, you can check out the TimescaleDB section in our documentation, and find out what you can do with it.

If you want to work through some tutorials to help you get up and running with TimescaleDB and time-series data, check out our tutorials section.

You can always contact us if you need help working something out, or if you want to have a chat.

Found an issue on this page?

Report an issue!


Related Content