Fly Postgres attach has SSL error

When running a simple fastapi app with postgres and default config I’m getting several Postgres errors.

First try

Without changing anything I get

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres

My connection string is basically

DATABASE_URL=postgres://<app name>:<password>@<db app name>.flycast:5432/<app name>?sslmode=disable

second try

from sqlalchemy.engine.url import make_url
url = make_url(settings.database_url)

# Modify the URL to use postgresql:// if needed
if url.drivername == "postgres":
    url = url.set(drivername="postgresql")

# Add query parameters to disable SSL
# url = url.update_query_dict({"sslmode": "disable"})

# Convert back to string
database_url = url.render_as_string(hide_password=False)
logging.warn(f"DB file: {database_url=}")
database = Database(database_url)


engine = create_engine(database_url)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base.metadata.create_all(bind=engine)

I can see my connection string logging correctly, with new driver name, but now I get

2024-09-24T18:54:57.046 runner[7816229c944718] bos [info] Configuring firecracker

2024-09-24T18:55:21.597 proxy[7816229c944718] bos [info] Starting machine

2024-09-24T18:55:21.658 app[7816229c944718] bos [info] 2024-09-24T18:55:21.658148001 [01J8JP5Y24WHSGZ9Q92ZW7PAG3:main] Running Firecracker v1.7.0

2024-09-24T18:55:21.996 app[7816229c944718] bos [info] [ 0.274959] PCI: Fatal: No config space access function found

2024-09-24T18:55:22.307 app[7816229c944718] bos [info] INFO Starting init (commit: 8cdad48f)...

2024-09-24T18:55:22.388 app[7816229c944718] bos [info] INFO Preparing to run: `.venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000` as root

2024-09-24T18:55:22.390 app[7816229c944718] bos [info] INFO [fly api proxy] listening at /.fly/api

2024-09-24T18:55:22.395 app[7816229c944718] bos [info] 2024/09/24 18:55:22 INFO SSH listening listen_address=[fdaa:a:3fd6:a7b:12:6aa5:68c4:2]:22 dns_server=[fdaa::3]:53

2024-09-24T18:55:22.424 runner[7816229c944718] bos [info] Machine started in 825ms

2024-09-24T18:55:22.425 proxy[7816229c944718] bos [info] machine started in 828.134957ms
...

2024-09-24T18:55:23.789 app[7816229c944718] bos [info] ERROR:root:Failed to connect to the database:

2024-09-24T18:55:23.793 app[7816229c944718] bos [info] ERROR: Traceback (most recent call last):

2024-09-24T18:55:23.793 app[7816229c944718] bos [info] File "/app/.venv/lib/python3.9/site-packages/starlette/routing.py", line 693, in lifespan
...
2024-09-24T18:54:51.027 app[7816229c944718] bos [info] File "uvloop/loop.pyx", line 1638, in start_tls

2024-09-24T18:54:51.027 app[7816229c944718] bos [info] File "uvloop/loop.pyx", line 1631, in uvloop.loop.Loop.start_tls

2024-09-24T18:54:51.027 app[7816229c944718] bos [info] File "uvloop/sslproto.pyx", line 517, in uvloop.loop.SSLProtocol._on_handshake_complete

2024-09-24T18:54:51.027 app[7816229c944718] bos [info] ConnectionResetError

2024-09-24T18:54:51.027 app[7816229c944718] bos [info] ERROR: Application startup failed. Exiting.

also tried

url = url.set(drivername="postgresql+psycopg2")

with same ConnectionResetError