PostgreSQL connection issue with Convex

hsb-tonmoyHOBBY

8 days ago

2025-06-05T02:43:12.890493Z ERROR common::errors: Caught error (RUST_BACKTRACE=1 RUST_LOG=info,common::errors=debug for full trace): Error occurred while creating a new object: error performing TLS handshake: invalid peer certificate: Other(OtherError(CaUsedAsEndEntity)): error performing TLS handshake: invalid peer certificate: Other(OtherError(CaUsedAsEndEntity)): invalid peer certificate: Other(OtherError(CaUsedAsEndEntity))
Error: Error occurred while creating a new object: error performing TLS handshake: invalid peer certificate: Other(OtherError(CaUsedAsEndEntity))

I deployed a standard PostgreSQL database and I'm trying to connect to it from a Convex backend that I deployed using the Convex template for Railway.

These are the env variables I have set in Convex:

POSTGRES_URL="postgresql://postgres:password@postgres.railway.internal:5432"
DO_NOT_REQUIRE_SSL="1"

I've tried it with both DO_NOT_REQUIRE_SSL set and unset, but I get the same error.

$10 Bounty

5 Replies

8 days ago

Don't worry, this is a common mistake and has an easy fixx. You'll just have to add ?sslmode=disable to your POSTGRES_URL, like this: postgresql://postgres:password@postgres.railway.internal:5432/dbname?sslmode=disable

And btw it's safe to remove the DO_NOT_REQUIRE_SSL (it’s not needed). This disables SSL verification and should fix the error.

If it doesn't fix it, share a screenshot so we can help.


testuser123

Don't worry, this is a common mistake and has an easy fixx. You'll just have to add ?sslmode=disable to your POSTGRES_URL, like this: postgresql://postgres:password@postgres.railway.internal:5432/dbname?sslmode=disableAnd btw it's safe to remove the DO_NOT_REQUIRE_SSL (it’s not needed). This disables SSL verification and should fix the error.If it doesn't fix it, share a screenshot so we can help.

hsb-tonmoyHOBBY

8 days ago

Of the logs? Here it is.

Attachments


hsb-tonmoy

Of the logs? Here it is.

8 days ago

sorry, accidentally clicked to publish; just edited the answer.


testuser123

sorry, accidentally clicked to publish; just edited the answer.

hsb-tonmoyHOBBY

8 days ago

The only problem with that is, Convex explicitly requires you not to include the DB name or any query params in the database URL:

Attachments


hsb-tonmoy

The only problem with that is, Convex explicitly requires you not to include the DB name or any query params in the database URL:

8 days ago

An alternative is to keep the POSTGRES_URL simple, no DB or params. Instead just add PGSSLMODE=disable to env vars. This disables SSL verification and fixes the TLS error with Convex.