Skip to content
Live $100 credit at signup, up to $300 total Offer ends December 31, 2026 Get started →

PostgreSQL

PostgreSQL is an open-source object-relational database known for its reliability, standards compliance, and extensibility. It supports advanced data types, full-text search, JSON, and a wide range of extensions.

PostgreSQL is published as one image per supported major version. Pick 16, 17, or 18 when you deploy.

ComponentVersion
PostgreSQL16.x, 17.x, or 18.x (per template)
Ubuntu24.04 LTS

You can optionally set these when deploying PostgreSQL from the marketplace. Leave any field blank to have a secure random value generated automatically.

VariableDescription
POSTGRES_PASSWORDPassword for the postgres superuser
POSTGRES_DBName of the application database to create
POSTGRES_USERApplication database username
ssh ubuntu@<your-vm-ip>

On the first boot, a setup script runs automatically. It generates a random password for the postgres superuser and saves it to /etc/postgresql/postgres-password.txt. This takes under 30 seconds.

Track progress:

journalctl -u postgresql-first-boot.service -f
sudo cat /etc/postgresql/postgres-password.txt

This file contains the postgres superuser password. It is only readable by root.

PG_PASS=$(sudo cat /etc/postgresql/postgres-password.txt)
psql -U postgres -h 127.0.0.1 -p 5432 -W

Enter the password from the credentials file when prompted.

To avoid the password prompt, set the PGPASSWORD environment variable:

PGPASSWORD="$PG_PASS" psql -U postgres -h 127.0.0.1
# Check service status
systemctl status postgresql
# Restart
sudo systemctl restart postgresql
# View logs
sudo journalctl -u postgresql -f

Configuration directory: /etc/postgresql/<major-version>/main/

Key files:

  • postgresql.conf: server settings
  • pg_hba.conf: client authentication rules

To allow remote connections, set listen_addresses = '*' in postgresql.conf and add an entry in pg_hba.conf. Restart PostgreSQL and open the firewall for specific IPs only (see Security).

Port 5432 is not open externally by default. UFW is enabled and allows SSH (port 22) only.

To allow access from a specific IP:

sudo ufw allow from <trusted-ip> to any port 5432

To connect without opening the firewall (recommended), use an SSH tunnel:

# Run this on your local machine
ssh -L 5432:localhost:5432 ubuntu@<your-vm-ip>
# Then connect locally
psql -U postgres -h 127.0.0.1