Supported Databases
- SQLite
- MySQL
- PostgreSQL
SQLite is the default database and recommended for most users. It’s a file-based database that requires no additional setup.
Advantages
- Zero configuration
- No separate database server required
- Perfect for single-instance deployments
- Easy backups (just copy the file)
Configuration
.env
Production Default
In production environments, ifDB_URL is not set, Homarr defaults to:Setup
- Set the environment variables in your
.envfile - Start Homarr - the database file will be created automatically
- Migrations run automatically on first startup
Database Migrations
Homarr uses Drizzle ORM for database migrations. Migrations are automatically applied when Homarr starts.Migration Files
Migrations are located in thepackages/db/migrations/ directory:
Automatic Migrations
Migrations run automatically in the following order:- Schema migrations - Create/update tables and columns
- Seed data - Insert default data (groups, settings)
- Custom migrations - Data transformations and updates
Manual Migration (Development)
For development, you can run migrations manually:Custom Migrations
Homarr includes custom migrations for data transformations:- 0000_release_widget_provider_to_options.ts - Migrates widget provider data to options format
- 0001_opnsense_credentials.ts - Updates OPNsense integration credentials
- 0002_app_widget_show_description_tooltip_to_display_mode.ts - Migrates tooltip settings to display mode
Connection Troubleshooting
SQLite Issues
Permission denied
Permission denied
Ensure the directory exists and Homarr has write permissions:
Database is locked
Database is locked
SQLite doesn’t support multiple concurrent writers. Ensure only one Homarr instance is using the database file.
MySQL Issues
Access denied for user
Access denied for user
Verify user permissions:Grant all privileges if needed:
Connection refused
Connection refused
Check if MySQL is running and accessible:Verify
DB_HOST and DB_PORT are correct.PostgreSQL Issues
Connection refused
Connection refused
Check PostgreSQL is running:Edit
postgresql.conf to ensure PostgreSQL listens on the correct interface:Database does not exist
Database does not exist
Create the database:
Backup and Restore
SQLite Backup
SQLite databases are simple files - just copy them:MySQL Backup
PostgreSQL Backup
Database Maintenance
SQLite Maintenance
Optimize database periodically:MySQL Maintenance
Optimize tables:PostgreSQL Maintenance
Vacuum and analyze:Migrating Between Databases
To migrate from one database type to another:- Export data from old database
- Set up new database with correct
DB_DRIVER - Start Homarr (migrations will run)
- Use database-specific tools to migrate data
Performance Tuning
SQLite
MySQL
Editmy.cnf:
PostgreSQL
Editpostgresql.conf:
Next Steps
- Environment Variables - Complete variable reference
- Authentication Providers - Set up user authentication
- CLI Commands - Manage your database with CLI tools
