Prisma database name overwritten with localhost IP

I am new to prisma and have no idea how to fix this problem, an unusual issue:
export const prisma = remember('prisma', () => {
const connectionString = ${process.env.DATABASE_URL};
const adapter = new PrismaPg({ connectionString });

const client = new PrismaClient({
adapter,
});
void client.$connect();
return client;
});
export const prisma = remember('prisma', () => {
const connectionString = ${process.env.DATABASE_URL};
const adapter = new PrismaPg({ connectionString });

const client = new PrismaClient({
adapter,
});
void client.$connect();
return client;
});
when I run npx prisma migrate deploy, DB is migrated and the tables are created. but when I run the app, the client gives me following error: User was denied access on the database localhost. Error: P1010. With the same connection url string for client and migration, why the client is using localhost? In prisma debug mode the logs are following, despite correct connectionString in adapter somehow the database name is overwritten with localhost IP
PrismaPgAdapterFactory {
provider: 'postgres',
adapterName: '@prisma/adapter-pg',
config: {
connectionString: 'postgresql://test:<redacted-password>@<db-url>:5432/test?schema=test\n'
},
options: undefined
}

prisma:client:request_handler {
"code": "P1010",
"meta": {
"database_name": "<container_ip>"
},
"clientVersion": "6.7.0",
"name": "PrismaClientKnownRequestError"
}
PrismaPgAdapterFactory {
provider: 'postgres',
adapterName: '@prisma/adapter-pg',
config: {
connectionString: 'postgresql://test:<redacted-password>@<db-url>:5432/test?schema=test\n'
},
options: undefined
}

prisma:client:request_handler {
"code": "P1010",
"meta": {
"database_name": "<container_ip>"
},
"clientVersion": "6.7.0",
"name": "PrismaClientKnownRequestError"
}
I manually ran npx prisma generate in the container, it found the env variables and loaded them and it did its job. Then I tried to run the client, the output was:
prisma:tryLoadEnv Environment variables not found at null +8ms
prisma:tryLoadEnv Environment variables loaded from /app/.env +1ms
postgresql://test:<redacted-password>@<db-url>:5432/test?schema=test
prisma:tryLoadEnv Environment variables not found at null +8ms
prisma:tryLoadEnv Environment variables loaded from /app/.env +1ms
postgresql://test:<redacted-password>@<db-url>:5432/test?schema=test
and then the error still persists: User was denied access on the database <container_ip>
5 Replies
Prisma AI Help
Prisma AI Help3mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Nurul
Nurul3mo ago
Do you have another Postgres instance running on your host? Related GitHub Issue here: https://github.com/prisma/prisma/issues/13384
GitHub
migrate deploy: Error: P1010: User user was denied access on the ...
Bug description migrate deploy throws Error: P1010: User user was denied access on the database db.public How to reproduce run migrate deploy Expected behavior migrations should run and tables on t...
Nurul
Nurul3mo ago
GitHub
migrate deploy: Error: P1010: User user was denied access on the ...
Bug description migrate deploy throws Error: P1010: User user was denied access on the database db.public How to reproduce run migrate deploy Expected behavior migrations should run and tables on t...
Nurul
Nurul3mo ago
I found this discussion which I assume you have created: https://github.com/prisma/prisma/discussions/27496 We can continue conversation here or on GitHub Discussion
GitHub
Prisma database name overwritten with localhost IP · prisma prisma...
Question I am new to prisma and have no idea how to fix this problem, an unusual issue: export const prisma = remember(&#39;prisma&#39;, () =&gt; { const connectionString = ${process.env.DATABASE_U...
Luke
Luke2mo ago
I can confirm I am also having this same issue, from my local PC. I get "User was denied access on the database my_ip_address_redacted". I tried turning my local PostgreSQL instance off, but still same issue. This is only using the query compiler. It works fine without that enabled. I am also using Prisma 6.11.1. Destination DB is hosted on AWS RDS. Interestingly, if I turn on my local PostgreSQL instance and change DATABASE_URL to point to that instead, it seems to work and I don't get the error. cc: @Nurul Ahh I think I found the issue... Just for testing, I added ?sslmode=no-verify to the end of my connection string and it started working. I am guessing that the Rust engine automatically handles SSL negotiation somehow, but with the pg adapter it does not default to SSL, which some DB hosts may require by default. So with the pg adapter, you need to make sure its configured properly in the connection string. @Nurul, I don't really use GitHub so wondering if you could comment on the GitHub discussion about this and maybe mention it? I think this might be the solution. It might be worth adding something about this to the documentation. Bump

Did you find this page helpful?