Skip to content
Evolution API crashing with PostgreSQL P1000 authentication error (Railway internal Postgres)
lelosmundim-wq
OP

9 months ago

Hi everyone,

I'm trying to deploy Evolution API on Railway and connect it to a Railway PostgreSQL database, but the service keeps crashing during deployment with a Prisma authentication error.

Setup

  • Railway project with:
    • PostgreSQL service (online and running)
    • Evolution API service
  • DATABASE_URL is set using Railway environment variable reference (not manually typed)
  • Database and API are in the same Railway project/environment

Error shown in Deploy Logs

Error: P1000: Authentication failed against database server at `postgres`,
the provided database credentials for `user` are not valid.

Logs show:

Datasource "db": PostgreSQL database "evolution", schema "public" at "postgres:5432"
Prisma schema loaded from prisma/postgresql-schema.prisma
Migration failed

What I already tried

  • Redeploying the service
  • Restarting both Postgres and Evolution API
  • Recreating DATABASE_URL using Railway reference
  • Confirmed Postgres service is online
  • Confirmed environment variables are loading correctly

Question

Is there any additional configuration required for Evolution API + Railway Postgres?

Specifically:

  • Do I need to use DATABASE_PRIVATE_URL instead of DATABASE_URL?
  • Does Railway require a different host format for Prisma migrations?
  • Is there a known issue with Prisma migrations resolving postgres hostname internally?

Any guidance would be greatly appreciated — I'm fairly new to Railway deployments.

Thanks in advance

$10 Bounty

2 Replies

lu4p

9 months ago

You should use the internal url to not pay for egress between your app and database. Also make sure that prisma is reading the right env variables.

See this article in how to setup env vars correctly.

https://www.prisma.io/docs/orm/core-concepts/supported-databases/postgresql

That said using the public url should work in principle although it's better to use the internal url.

You're likely shipping a .env file which overrides DATABASE_URL to something else, or have the Prisma client setup in a way where it expects another env var.


Anonymous

16 days ago

The first thing to correct is the variable name. Evolution API’s PostgreSQL schema reads DATABASE_CONNECTION_URI; setting a correct DATABASE_URL alone does not configure that datasource.

In the Evolution API service, set:

DATABASE_PROVIDER=postgresql
DATABASE_CONNECTION_URI=${{Postgres.DATABASE_URL}}

Use your actual database service name instead of Postgres, or reuse the internal Railway reference you already created. Confirm the intended database and preserve any required schema parameter before redeploying: the standard image runs migrations at startup.

The upstream Dockerfile includes an example .env, and its migration wrapper loads it. A missing DATABASE_CONNECTION_URI can therefore retain an example value even when DATABASE_URL is correct. Your user / postgres:5432 values are consistent with stale/example settings, although they do not establish which image you are running.

If you added DATABASE_URL solely for Evolution, remove that unused variable after setting the correct one: this revision’s launcher prints its raw value but never maps it to DATABASE_CONNECTION_URI.

Redeploy Evolution and check Prisma’s datasource line for the expected host, database and schema. Do not share the full connection string. If it still fails, share the image name/tag, any custom start command, and the next error with secrets removed.

AI-assisted answer, checked against upstream source at 8ab41fc. Your image tag was not provided; this has not been tested against your running deployment.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...