<@ULVA73B9P>: How can I tell if my Prefect self-ho...
# marvin-ai
c
@Marvin: How can I tell if my Prefect self-hosted instance is using my Postgres database or falling back to the SQLite database?
m
thought for 107.2 seconds
A few reliable ways: 1. Check the configured DB URL If your server is using PostgreSQL,
PREFECT_SERVER_DATABASE_CONNECTION_URL
should look like
postgresql+asyncpg://...
. If it’s falling back to SQLite, it will look like
sqlite+aiosqlite:///...
, often something like
~/.prefect/prefect.db
. Quick check:
Copy code
bash
echo $PREFECT_SERVER_DATABASE_CONNECTION_URL
env | grep -i "PREFECT_SERVER_DATABASE\|PREFECT_API_DATABASE"
Or from Python:
Copy code
bash
python -c "from prefect.settings import get_current_settings; print(get_current_settings().server.database.connection_url)"
2. Check what Prefect resolved at runtime This is the clearest verification:
Copy code
bash
python -c "
from prefect.settings import get_current_settings
from prefect.server.utilities.database import get_dialect

url = get_current_settings().server.database.connection_url.get_secret_value()
dialect = get_dialect(url)

print(f'Database URL: {url}')
print(f'Dialect: {dialect.name}')
"
You should see either: -
Dialect: postgresql
-
Dialect: sqlite
3. Check for the default SQLite file If Prefect fell back to SQLite, you’ll usually find:
Copy code
bash
ls -lh ~/.prefect/prefect.db
If that file exists and is being updated while the server is running, that’s a strong sign you’re on SQLite. You can also inspect it:
Copy code
bash
sqlite3 ~/.prefect/prefect.db ".tables"
4. Inspect your Postgres directly If you expect Postgres, connect to it and see whether Prefect tables exist:
Copy code
bash
psql -h <host> -U <user> -d <database_name> -c "\dt"
If you see Prefect tables there, your server is likely using Postgres. 5. Watch server behavior/logs SQLite has some special behavior in Prefect: - request limiting middleware is applied to reduce SQLite lock contention - you may see SQLite-style locking symptoms under load - multi-worker server setups are not appropriate with SQLite Postgres won’t use that SQLite-specific path. Most important thing to know In Prefect 3.x, if you don’t explicitly configure the server DB, Prefect defaults to SQLite. So the simplest answer is: - if
connection_url
resolves to
postgresql+asyncpg://...
→ you’re on Postgres - if it resolves to
sqlite+aiosqlite:///...
→ you’re on SQLite fallback Recommended quick diagnostic
Copy code
bash
python -c "
from prefect.settings import get_current_settings
from prefect.server.utilities.database import get_dialect

settings = get_current_settings()
url = settings.server.database.connection_url.get_secret_value()
print('Resolved DB URL:', url)
print('Resolved DB dialect:', get_dialect(url).name)
"
Relevant docs: - Self-host Prefect: configure a database - Prefect self-hosting guides If you want, I can also help you check a specific Docker Compose / Helm / environment setup to confirm whether it’s correctly pointing at Postgres.