database does not exist
This error occurs when you try to connect to a database that doesn't exist in the PostgreSQL server.
The database does not exist error means the specified database wasn't found.
Understanding the Error
FATAL: database "myapp" does not exist
You're trying to connect to a database that hasn't been created.
Common Causes
1. Database Not Created
BASH
2. Typo in Database Name
BASH
3. Wrong Environment
Connecting to production when database only exists in development, or vice versa.
4. Case Sensitivity
BASH
How to Fix It
Solution 1: Create the Database
SQL
Solution 2: List Available Databases
SQL
Solution 3: Create with Template
SQL
Solution 4: Check Connection String
JAVASCRIPT
Solution 5: Use createdb Command
BASH
Solution 6: Connect to Default Database First
BASH
Database Naming Best Practices
SQL
Best Practices
- Use consistent naming across environments
- Script database creation for reproducibility
- Use lowercase names without special characters
- Check environment before running commands
- Include database setup in deployment scripts