PostgreSQL 15 still fits workloads that need the MERGE statement and established extension compatibility, especially when the rest of the stack is not ready for a newer PostgreSQL major yet. To install PostgreSQL 15 on Debian, the release split matters: Debian 12 carries it in the default archive, while Debian 13 and Debian 11 need the PostgreSQL APT repository.
These steps cover Debian 13 (Trixie), Debian 12 (Bookworm), and Debian 11 (Bullseye). Once the packages are installed, Debian’s pg_lsclusters tooling gives you a quick sanity check before you create a role, add a database, or decide whether you only need the client tools.
Install PostgreSQL 15 on Debian
Update Debian Before Installing PostgreSQL 15
Refresh the package index and install pending upgrades first so PostgreSQL pulls against current system libraries:
sudo apt update && sudo apt upgrade
These commands use
sudowhen they need root privileges. If your account is not in the sudoers group yet, use the Debian guide to add a user to sudoers before continuing.
Compare PostgreSQL 15 Availability on Debian
This release split is the main Debian-specific detail that matters before you install anything. Debian 12 can install PostgreSQL 15 directly, while Debian 13 and Debian 11 need the PostgreSQL repository maintained by the PostgreSQL Global Development Group.
| Debian release | Default PostgreSQL version | PostgreSQL 15 in default repo | Best way to install PostgreSQL 15 |
|---|---|---|---|
| Debian 13 (Trixie) | 17.x | No | Use the PGDG repository |
| Debian 12 (Bookworm) | 15.x | Yes | Use the Debian 12 default repository |
| Debian 11 (Bullseye) | 13.x | No | Use the PGDG repository |
- Use the Debian 12 repository if you are on Bookworm and just want the standard PostgreSQL 15 server packages.
- Use PGDG on Debian 13 or Debian 11 because PostgreSQL 15 is not in those default repositories.
- Use PGDG on Debian 12 only if you want the newer 15.x minor releases from PostgreSQL upstream instead of Debian’s package track.
- Install only
postgresql-client-15if you needpsqlandpg_dumpfor a remote server but do not want a local database cluster.
On Bookworm, the default repository is the simpler choice because Debian already ships PostgreSQL 15 and keeps it patched through Debian security updates. On Trixie and Bullseye, PGDG is the only practical path for this major release.
These steps work across Debian 13, 12, and 11. The only real branch is repository choice: Bookworm installs PostgreSQL 15 straight from Debian, while Trixie and Bullseye use PGDG. After that split, the package names and cluster checks stay the same.
Install PostgreSQL 15 from the Debian 12 Repository
If you are on Debian 12, this is the shortest and cleanest install path because PostgreSQL 15 already lives in the standard Debian archive:
sudo apt install postgresql-15 postgresql-client-15
The server package creates the default 15/main cluster automatically, and the client package gives you psql, pg_dump, and the other command-line tools you use for day-to-day administration.
Verify the installed version and confirm that Debian created the cluster:
psql --version
pg_lsclusters
psql (PostgreSQL) 15.16 (Debian 15.16-0+deb12u1) Ver Cluster Port Status Owner Data directory Log file 15 main 5432 online postgres /var/lib/postgresql/15/main /var/log/postgresql/postgresql-15-main.log
The online status is the important part. On Debian, pg_lsclusters is the quickest way to confirm that the packaged cluster exists, which port it uses, and where its data and log files live.
Install PostgreSQL 15 from the PostgreSQL APT Repository
Use this method on Debian 13 or Debian 11, or on Debian 12 if you want PostgreSQL 15 packages that track PGDG’s newer 15.x minor releases. The PostgreSQL project documents the repository on its Debian download page, but the commands below use Debian’s preferred DEB822 format.
Install the packages needed to import the signing key and build the repository file:
sudo apt install ca-certificates curl gpg -y
Import the PostgreSQL signing key into Debian’s keyring path:
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo gpg --dearmor -o /usr/share/keyrings/postgresql.gpg
Now create the DEB822 repository file. The commands read your Debian codename from /etc/os-release, which is safer than relying on lsb_release being installed:
CODENAME=$(. /etc/os-release && echo "$VERSION_CODENAME")
ARCH=$(dpkg --print-architecture)
cat <<EOF | sudo tee /etc/apt/sources.list.d/postgresql.sources >/dev/null
Types: deb
URIs: https://apt.postgresql.org/pub/repos/apt
Suites: ${CODENAME}-pgdg
Components: main
Architectures: ${ARCH}
Signed-By: /usr/share/keyrings/postgresql.gpg
EOF
Refresh APT metadata and verify that postgresql-15 now resolves from PGDG:
sudo apt update
apt-cache policy postgresql-15
APT should mention the PGDG source during the refresh:
Hit:4 https://apt.postgresql.org/pub/repos/apt trixie-pgdg InRelease
postgresql-15:
Installed: (none)
Candidate: 15.17-1.pgdg13+1
Version table:
15.17-1.pgdg13+1 500
500 https://apt.postgresql.org/pub/repos/apt trixie-pgdg/main amd64 Packages
15.16-1.pgdg13+1 500
500 https://apt.postgresql.org/pub/repos/apt trixie-pgdg/main amd64 Packages
A first refresh may show
Getinstead ofHit. On Debian 12, the PGDG lines change tobookworm-pgdgand the candidate becomes15.17-1.pgdg12+1. On Debian 11, they change tobullseye-pgdgand15.17-1.pgdg11+1. The important check is that both commands point toapt.postgresql.organd your release suffix ends with-pgdg.
Install PostgreSQL 15 from PGDG with the same package names used on Debian 12:
sudo apt install postgresql-15 postgresql-client-15
Verify the PGDG build and confirm that the cluster came online:
psql --version
pg_lsclusters
psql (PostgreSQL) 15.17 (Debian 15.17-1.pgdg13+1) Ver Cluster Port Status Owner Data directory Log file 15 main 5432 online postgres /var/lib/postgresql/15/main /var/log/postgresql/postgresql-15-main.log
If you already installed the Debian 12 archive build and later decide to move to PGDG, add the repository first and rerun the same install command. APT will prefer the newer PGDG package when it has the higher candidate version.
Install Only the PostgreSQL 15 Client Tools on Debian
If the database server runs somewhere else and you only need psql, pg_dump, and the client libraries, install just the client package after choosing the repository path that matches your Debian release:
sudo apt install postgresql-client-15
Verify that the client tools are available:
psql --version
psql (PostgreSQL) 15.17 (Debian 15.17-1.pgdg13+1)
On Debian 12 using the default repository, the version string ends with Debian’s 15.16-0+deb12u1 package instead of a pgdg build tag.
Check the PostgreSQL 15 Service on Debian
Debian packages PostgreSQL through postgresql-common, which is why the wrapper service can show active (exited) while the cluster itself is online. Check the wrapper service first, then confirm the cluster state with pg_lsclusters if you want the per-cluster view.
systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: enabled)
Active: active (exited) since Wed 2026-03-04 13:22:57 AWST; 2h 39min ago
Main PID: 8144 (code=exited, status=0/SUCCESS)
That status is normal on Debian. The wrapper starts and hands cluster management off to the PostgreSQL processes behind it, so pg_lsclusters is the better check when you need to confirm that 15/main is actually running.
| Task | Command |
|---|---|
| Check cluster status | pg_lsclusters |
| Restart PostgreSQL after config changes | sudo systemctl restart postgresql |
| Stop PostgreSQL | sudo systemctl stop postgresql |
| Start PostgreSQL | sudo systemctl start postgresql |
| View recent service logs | sudo journalctl -u postgresql --no-pager -n 20 |
Create a PostgreSQL 15 Role and Database on Debian
The default local authentication method lets the Linux postgres account administer the server without a password. That makes the initial role-and-database setup straightforward.
Create a login role and a database owned by that role:
sudo -iu postgres psql -c "CREATE ROLE appuser WITH LOGIN PASSWORD 'change_this_password';"
sudo -iu postgres psql -c "CREATE DATABASE appdb OWNER appuser;"
CREATE ROLE CREATE DATABASE
Replace appuser, appdb, and change_this_password with values that fit your application. If the database server only needs local clients, keep using 127.0.0.1 or the local Unix socket instead of opening PostgreSQL to the network.
Verify that the new role can connect to its database:
PGPASSWORD='change_this_password' psql -h 127.0.0.1 -U appuser -d appdb -c '\conninfo'
You are connected to database "appdb" as user "appuser" on host "127.0.0.1" at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
If you want an interactive shell instead of a one-shot query, open it with sudo -iu postgres psql and leave with \q when you are done.
Update PostgreSQL 15 on Debian
PostgreSQL 15 minor releases install through normal APT updates, regardless of whether you used the Debian archive or PGDG. Update only PostgreSQL 15 and its matching client tools with:
sudo apt update
sudo apt install --only-upgrade postgresql-15 postgresql-client-15
Debian 12 follows Debian’s packaged 15.x update track, while PGDG tracks newer upstream 15.x releases until PostgreSQL 15 reaches end of life on November 11, 2027 according to PostgreSQL’s versioning policy.
Troubleshoot PostgreSQL 15 Installation on Debian
Fix “Unable to Locate Package postgresql-15” on Debian
On Debian 13 or Debian 11, trying to install PostgreSQL 15 from the default repositories fails because that package does not exist in the base archive for those releases:
E: Unable to locate package postgresql-15
Confirm what Debian offers by default on your release:
apt-cache policy postgresql
postgresql:
Installed: (none)
Candidate: 17+278
Version table:
17+278 500
500 http://deb.debian.org/debian trixie/main amd64 Packages
That candidate line is the clue. On Debian 13, the default meta package points to PostgreSQL 17. On Debian 11, it points to PostgreSQL 13. Add the PGDG repository, run sudo apt update, and verify that apt-cache policy postgresql-15 now shows a PGDG candidate before you install.
Remove PostgreSQL 15 from Debian
When you no longer need PostgreSQL 15, remove the server and client packages first:
sudo systemctl stop postgresql
sudo apt remove postgresql-15 postgresql-client-15
sudo apt autoremove
If you used the PGDG repository, remove the repository file and signing key after the package removal:
sudo rm -f /etc/apt/sources.list.d/postgresql.sources
sudo rm -f /usr/share/keyrings/postgresql.gpg
sudo apt update
The next commands permanently delete the PostgreSQL 15 data directory and cluster configuration. Back up anything you need first with
pg_dumpor your normal backup workflow before removing these paths.
sudo rm -rf /var/lib/postgresql/15 /etc/postgresql/15
Verify that the PostgreSQL 15 server and client packages are no longer installed:
dpkg -l postgresql-15 postgresql-client-15 | grep '^ii' || echo "PostgreSQL 15 packages are no longer installed."
PostgreSQL 15 packages are no longer installed.
Frequently Asked Questions about PostgreSQL 15 on Debian
Yes. Debian 12 ships PostgreSQL 15 in its default repositories, so Bookworm users can install it directly with apt without adding PGDG.
postgresql-15?
Debian 13 ships PostgreSQL 17 in the default archive, not PostgreSQL 15. Add the PostgreSQL APT repository from the PostgreSQL Debian download page, run apt update, and then install postgresql-15.
Yes. If Debian 12 has the PGDG repository configured, apt sees the PGDG build as the newer candidate for postgresql-15 and prefers it on the next install or upgrade. PostgreSQL 15 stays the same major version, but updates come from PGDG instead of Debian’s default archive.
PostgreSQL 15 reaches end of life on November 11, 2027 according to PostgreSQL’s official versioning policy. After that date, new security and bug-fix releases stop for that major version.
Conclusion
PostgreSQL 15 on Debian is up and running with a live 15/main cluster, working client tools, and a straightforward path for either Debian-managed or PGDG-managed updates. If remote access comes next, lock it down with UFW on Debian and keep administration access reliable with SSH on Debian.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><a href="URL">link</a><blockquote>quote</blockquote>