#Weird error self-hosting
11 messages · Page 1 of 1 (latest)
That specific error (cluster url username must be set) is coming from the database connection string your backend is using.
From a very similar Discord thread, this error was traced to the Postgres connection URL not having a proper username in it. [Self host thread]
In the self‑hosting docs, when using Postgres you’re expected to set a full connection URL via DATABASE_URL / POSTGRES_URL, e.g.: [Option 3 docs]
DATABASE_URL=postgresql://user:[email protected]
# with a database named convex_self_hosted
And in the example Docker config from that thread, they had:
- DATABASE_URL=${CONVEX_DATABASE_URL:-postgresql://postgres:postgres@localhost:5432}
- POSTGRES_URL=${POSTGRES_URL:-postgresql://postgres:postgres@localhost:5432}
So to debug:
-
Check what URL is actually being passed into the container:
- Run
docker compose configand look at the resolvedDATABASE_URL/POSTGRES_URL. - Make sure it’s not empty and that it includes a username (the
userpart inpostgresql://user:password@host:port).
- Run
-
Prefer
POSTGRES_URLoverDATABASE_URL
The log you pasted showsDATABASE_URL is deprecated. The current recommendation is to set:environment: - POSTGRES_URL=postgresql://postgres:postgres@convex-postgres:5432(Note: use the Postgres service name from your
docker-compose.ymlinstead oflocalhostso the backend can reach it from inside the Docker network.) [Option 3 docs]
- Ensure the DB exists and is reachable
The docs expect a database namedconvex_self_hostedwhen using Postgres. [Option 3 docs]
Your URL should look like:POSTGRES_URL=postgresql://postgres:postgres@convex-postgres:5432/convex_self_hosted
If you share your docker-compose.yml (with secrets redacted), you can compare it directly to the example in the self‑hosting README and the Discord snippet above to make sure the env vars line up. [Self-host README; Self host thread]
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@craggy breach Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Let me check the knowledge base for you again. One moment! :books:
The error is coming from how the Convex backend is connecting to Postgres: it’s trying to use TLS, but your Postgres server is running without TLS:
error performing TLS handshake: server does not support TLS
In the official self‑hosting docs, the Postgres connection is configured via POSTGRES_URL (or the now‑deprecated DATABASE_URL) as a standard connection string, e.g.: [Option 3 docs]
POSTGRES_URL=postgresql://user:[email protected]
However, the knowledge sources don’t document any flags or URL parameters to force TLS off or choose TLS mode; they only say to provide a normal Postgres URL and ensure a convex_self_hosted database exists. [Option 3 docs]
Because of that, I can’t confidently tell you how to switch the Convex backend to a non‑TLS connection from the docs alone.
What you can do, based on the docs:
-
Double‑check your
POSTGRES_URL/DATABASE_URL
Make sure it’s set and points at your Postgres instance, e.g.:environment: - POSTGRES_URL=postgresql://postgres:postgres@convex-postgres:5432/convex_self_hostedwhere
convex-postgresis the service name from yourdocker-compose.yml. [Self-host README; Option 3 docs]
-
Compare against the official Docker examples
The self‑hosting README and theself-hosted/dockersetup show the expected environment variables and patterns; aligning your compose file with those is the safest path. [Self-host README; Self-hosting setup] -
If you’re using a managed Postgres (like Neon)
The docs explicitly mention Neon and only require settingDATABASE_URL/POSTGRES_URLand creating theconvex_self_hostedDB; they don’t mention TLS toggles. [Option 3 docs]
Given the lack of TLS‑specific configuration in the knowledge sources, the best next step is to:
- Post your
docker-compose.yml(with secrets redacted) and the exactPOSTGRES_URLyou’re using in the#self-hostedchannel on Discord, which is where the Convex team directs self‑hosting questions. [Self-host README; Questions & contributions]
That way they can confirm whether the backend currently always expects TLS for external Postgres, or if there’s a documented way (not present in these sources) to connect to a non‑TLS Postgres instance.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@craggy breach Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Let me check the knowledge base for you again. One moment! :books:
The knowledge sources don’t describe TLS options or sslmode handling for POSTGRES_URL, so I can’t say for sure how ?sslmode=disable is interpreted by the backend. I’ll stick to what is documented and what’s clearly off in your compose file.
1. Your healthcheck DB name is wrong
Your Postgres service:
db:
image: postgres
volumes:
- db_data:/var/lib/postgresql
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: convex_self_hosted
healthcheck:
test: [ "CMD-SHELL", "pg_isready", "-d", "db_prod" ]
You create convex_self_hosted but the healthcheck probes db_prod. The self‑hosting docs explicitly say to create a DB named convex_self_hosted when using Postgres. [Option 3]
Change the healthcheck to:
healthcheck:
test: [ "CMD-SHELL", "pg_isready", "-d", "convex_self_hosted" ]
2. Use the documented Postgres URL shape
Docs show:
DATABASE_URL=postgresql://user:[email protected]
# and then create a DB called convex_self_hosted
``` [[Option 3](<https://stack.convex.dev/self-hosted-develop-and-deploy#option-3-docker-containers-on-a-remote-server>)]
Your backend env:
```yaml
- POSTGRES_URL=postgresql://postgres:password@db:5432?sslmode=disable
Two issues relative to the docs:
- No database name in the URL.
sslmode=disableis not mentioned anywhere in the docs, so behavior is unclear.
To align with the docs, try:
environment:
- POSTGRES_URL=postgresql://postgres:password@db:5432/convex_self_hosted
(Use the service name db as you already do; that’s correct for Docker networking.)
3. Prefer POSTGRES_URL and drop DATABASE_URL
You already set POSTGRES_URL, which is the recommended variable; DATABASE_URL is deprecated. [Option 3]
Right now you have:
- DATABASE_URL
- POSTGRES_URL=postgresql://postgres:password@db:5432?sslmode=disable
If DATABASE_URL is set in your shell, it may conflict. To be safe, either:
- Unset
DATABASE_URLin your environment beforedocker compose up, or - Remove
- DATABASE_URLfrom the compose file so onlyPOSTGRES_URLis used.
4. If TLS errors persist
The TLS handshake error you saw:
error performing TLS handshake: server does not support TLS
is not covered in the docs, and there’s no documented flag/env to force non‑TLS connections. The self‑hosting README explicitly points self‑hosting questions to the #self-hosted Discord channel. [Self-host README]
If, after:
- fixing the DB name in the healthcheck,
- using
postgresql://postgres:password@db:5432/convex_self_hosted, - and ensuring
DATABASE_URLisn’t conflicting,