<@ULVA73B9P> I am hosting a prefect server on AWS ...
# ask-marvin
d
@Marvin I am hosting a prefect server on AWS ECS Fargate, with a Postgres database. But I'm getting an error when the cluster task is spawning, here is one of the errors
asyncpg.*exceptions*.InvalidCatalogNameError: database "prefect" does not exist
m
thought for 99.1 seconds
Based on the research, I can help you resolve this error. The issue is that while you have PostgreSQL running, the actual database named "prefect" hasn't been created yet. Here's how to fix it: 1. Create the Database First Before starting the Prefect server, you need to create the database. You have several options: a. Using psql CLI:
Copy code
sql
   psql -U your_postgres_user -h your_host
   CREATE DATABASE prefect;
b. Using a PostgreSQL client or management tool:
Copy code
sql
   CREATE DATABASE prefect;
2. Enable Required Extension After creating the database, connect to it and enable the required extension:
Copy code
sql
   \c prefect
   CREATE EXTENSION IF NOT EXISTS pg_trgm;
3. Environment Configuration Ensure your ECS task definition includes the correct environment variable:
Copy code
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?