Kartik
02/19/2026, 7:55 AMMarvin
02/19/2026, 7:55 AMMarvin
02/19/2026, 8:00 AMcurl -i http://<your-host>:4200/api/health
curl -i http://<your-host>:4200/api/ready
Expect 200 for /health; /ready returns 200 only if the DB is reachable.
- Check server logs for DB or timeout errors
journalctl -u prefect-server -f
Look for “database unavailable”, timeouts, pool exhaustion, or 5xx traces.
2) Ensure the Postgres URL uses the async driver and run migrations
- Your Prefect server must point to Postgres with the async driver:
export PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://user:pwd@host:5432/prefect>"
echo $PREFECT_API_DATABASE_CONNECTION_URL
If you see plain postgresql:// (sync), switch to postgresql+asyncpg:// and restart.
- Apply migrations (this fixes schema/index issues that can cause slow or failing queries):
prefect server database upgrade -y
If your DB is large, set a higher timeout:
export PREFECT_API_DATABASE_TIMEOUT=600
prefect server database upgrade -y
3) Right‑size the DB connection pool for production
If the pool is too small, API calls will hang/timeout and you’ll see that UI toast.
- Start with:
export PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_SIZE=20
export PREFECT_SERVER_DATABASE_SQLALCHEMY_MAX_OVERFLOW=40
export PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_TIMEOUT=30
export PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_RECYCLE=3600
- Restart the server after setting these.
- Watch active connections to confirm you’re not exhausting the pool:
psql -c "SELECT count(*) FROM pg_stat_activity WHERE datname='prefect';"
4) If you’re behind a reverse proxy/ALB, verify routing and headers
- The UI expects the API at /api. Ensure your proxy forwards:
- All /api/* to the Prefect server
- WebSockets upgrade headers
- X-Forwarded-For / X-Forwarded-Proto / Host
- A misrouted /api path is a frequent cause of intermittent UI API errors.
5) Confirm the server picked up your env vars when running as a daemon
When using systemd/daemon, environment may not match your shell. Put env in the unit or an EnvironmentFile and restart:
- Minimal example:
[Service]
Environment="PREFECT_API_DATABASE_CONNECTION_URL=<postgresql+asyncpg://user:pwd@localhost:5432/prefect>"
Environment="PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_SIZE=20"
ExecStart=/usr/local/bin/prefect server start --no-services
Restart=always
- Validate at runtime:
prefect config view | grep -i database
6) Quick diagnostics to share back (will pinpoint the issue fast)
- Output of:
prefect version
prefect server database current
prefect config view | grep -E 'PREFECT_API_URL|DATABASE|POOL'
echo $PREFECT_API_DATABASE_CONNECTION_URL
curl -sS http://<host>:4200/api/health
curl -sS http://<host>:4200/api/ready
- Any reverse proxy/ALB config if applicable.
- Relevant lines from journalctl -u prefect-server -f around failures.
If you want a reference setup to compare against (single EC2, Postgres, Redis, server as a service), these guides are handy:
- Server CLI (self-hosted): Server CLI
- Docker Compose example (even if not using Docker, it shows working env): Docker Compose setup
- Advanced self-hosted/production notes: Scaling self-hosted
- Settings reference (DB and pool env vars): Settings referenceMarvin
02/19/2026, 8:00 AM