❤️ AZDIGI has officially updated to a new blog system. However, some posts may have incorrect or mismatched images. Please click the Report article button at the bottom of the post so AZDIGI can update as quickly as possible. Thank you!

Most applications require databases. Coolify allows you to create databases with just 1 click — PostgreSQL, MySQL, Redis, MongoDB… — complete with automatic backup and direct management from the dashboard.

📖 Previous article: Part 8, CI/CD with GitHub/GitLab

I. Supported Database Types

DatabaseDefault ImageUse case
PostgreSQLpostgres:16-alpinePrimary database for most apps
MySQLmysql:8.0WordPress, traditional PHP apps
MariaDBmariadb:11Drop-in replacement for MySQL
MongoDBmongo:7NoSQL, document-based apps
Redisredis:7-alpineCaching, session store, queue
KeyDBeqalpha/keydbRedis-compatible, multi-threaded
Dragonflydocker.dragonflydb.io/dragonflydb/dragonflyRedis alternative, high performance
ClickHouseclickhouse/clickhouse-serverAnalytics, time-series data

II. Creating a Database

PostgreSQL and MySQL databases on Coolify
PostgreSQL 16 and MySQL 8.0 running on Coolify, test connection
List of database types on Coolify
Choose database type: PostgreSQL, MySQL, MariaDB, Redis, MongoDB, ClickHouse…
  1. Go to Project → Environment → “+ Add Resource”
  2. Select database type (e.g., PostgreSQL)
  3. Choose server to deploy (localhost)
  4. Coolify automatically creates container with random password

After creation, the database is ready to use immediately with no additional configuration required.

III. Connection Strings

Coolify displays connection strings for each database:

Internal (same server)

# PostgreSQL
postgresql://postgres:RANDOM_PASS@CONTAINER_NAME:5432/postgres

# MySQL mysql://root:RANDOM_PASS@CONTAINER_NAME:3306/mysql

# Redis redis://CONTAINER_NAME:6379

# MongoDB mongodb://root:RANDOM_PASS@CONTAINER_NAME:27017

💡 Use internal connection string when app and database are on the same Coolify server. Traffic goes through Docker internal network, faster and more secure (no exposed ports to internet).

External (from outside)

If you need to access the database from outside (e.g., using DBeaver, pgAdmin from laptop):

  1. Go to database resource → enable “Publicly Accessible”
  2. Coolify maps port to host (e.g., 5432 → random port)
  3. Use connection string: postgresql://user:pass@SERVER_IP:MAPPED_PORT/db

🚨 Only enable “Publicly Accessible” when truly needed, exposing database to internet is a major security risk. Remember to disable when done.

IV. Connecting App to Database

Most common workflow:

  1. Create database (e.g., PostgreSQL) in the same project/environment
  2. Copy internal connection string
  3. Go to app resource → Environment Variables tab
  4. Add: DATABASE_URL = postgresql://postgres:xxx@container_name:5432/postgres
  5. Redeploy app

V. Automatic Database Backup

Automatic database backup
Coolify automatically backs up database daily, stored as .sql.gz

Coolify supports automatic database backup to S3-compatible storage:

Setup S3 Storage

  1. Go to S3 Storages“+ Add”
  2. Fill credentials: Endpoint, Region, Bucket, Access Key, Secret Key
  3. Click “Validate Connection”

ℹ️ S3-compatible storage includes: AWS S3, Cloudflare R2 (has free tier), MinIO (self-hosted), DigitalOcean Spaces, Backblaze B2. Cloudflare R2 is a good choice due to its free 10GB tier.

Configure Backup Schedule

  1. Go to database resource → “Backups” tab
  2. Select the configured S3 storage
  3. Set schedule (cron format): 0 2 * * * = backup at 2 AM daily
  4. Set retention: how many backups to keep
  5. Enable “Enabled”

Restore Backup

  1. Go to database → Backups tab
  2. Select the backup you want to restore
  3. Click “Restore”
  4. Coolify downloads backup from S3 and restores to database

VI. Database Management

  • Logs: View database logs real-time from dashboard
  • Execute Command: Run commands in container (psql, mysql, redis-cli…)
  • Restart: Restart database container
  • Custom Config: Mount custom config file (e.g., postgresql.conf, my.cnf)
  • Version: Change Docker image tag to upgrade/downgrade version

VII. Summary

Databases on Coolify are created with 1 click, connected via internal network (secure), with automatic backup to S3. No need to manage database servers, Coolify handles everything. Next article: One-Click Services, deploy 294+ services.

Share:
This article has been reviewed by AZDIGI Team

About the author

Trần Thắng

Trần Thắng

Expert at AZDIGI with years of experience in web hosting and system administration.

10+ years serving 80,000+ customers

Start your web project with AZDIGI