David Martin Calalang
07/31/2025, 8:43 PMasyncpg.*exceptions*.InvalidCatalogNameError: database "prefect" does not exist
Marvin
07/31/2025, 8:46 PMMarvin
07/31/2025, 8:48 PMsql
psql -U your_postgres_user -h your_host
CREATE DATABASE prefect;
b. Using a PostgreSQL client or management tool:
sql
CREATE DATABASE prefect;
2. Enable Required Extension
After creating the database, connect to it and enable the required extension:
sql
\c prefect
CREATE EXTENSION IF NOT EXISTS pg_trgm;
3. Environment Configuration
Ensure your ECS task definition includes the correct environment variable:
PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://username:password@your-postgres-host:5432/prefect>
4. Deployment Order
Make sure to:
1. Create the PostgreSQL database first
2. Enable the pg_trgm extension
3. Then start your Prefect server ECS task
If you're using AWS RDS for PostgreSQL, you can also create the database through the AWS CLI or AWS Console using RDS commands.
Common Gotchas to Check:
- Ensure the PostgreSQL user has permissions to create databases
- Verify the database name is exactly "prefect" (case sensitive)
- Check that your ECS task has network access to the PostgreSQL instance
- Verify the connection URL format in your environment variables
Would you like me to provide more specific details about any of these steps? Also, it would be helpful to know:
1. Are you using Amazon RDS or a self-managed PostgreSQL instance?
2. How are you currently trying to create the database?