Y
Y
yativ_sobb2022-02-06 22:22:55
PostgreSQL
yativ_sobb, 2022-02-06 22:22:55

How to solve User `postgres` was denied access on the database `.public`?

There is an error User `postgres` was denied access on the database `toncoin_bot.public`,
- Locally everything works fine
- Docker starts without problems

FROM node:15.13.0

RUN mkdir -p /project/node_modules && chown -R node:node /project

WORKDIR /project

COPY package*.json ./
COPY --chown=node:node prisma ./prisma
COPY config ./config

RUN npm install
RUN npx prisma generate
RUN npx prisma db push // и тут ошибок нет

COPY --chown=node:node ./temp ./temp
RUN ./temp/loadTarrifs.js // тут нет ошибок
COPY --chown=node:node . .

CMD [ "node", "index.js" ]

version: '3.8'

services:
  bot:
    build:
      context: .
      dockerfile: .dockerfile
    extra_hosts:
      - host.docker.internal:172.17.0.1
    volumes:
      - node_modules:/project/node_modules
      - ./workers:/project/workers
      - ./config/:/project/config
      - ./prisma:/project/prisma
  depositing:
    image: node:15.13.0
    working_dir: /project
    command: node workers/depositing.js
    volumes:
      - node_modules:/project/node_modules
      - ./workers:/project/workers
      - ./config/:/project/config
      - ./prisma:/project/prisma
...

- a one-time script running node ./temp/loadTarrifs.js Setting
Prism
DATABASE_URL=" postgresql://postgres:[email protected]:5432/m... "
But there is no access in the project, namely in the workers and the main service?
User `postgres` was denied access on the database `.my_db.public`

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
yativ_sobb, 2022-02-08
@yativ_sobb

I found what the problem is, the problem is in docker-compose, it does not use the default network. Wow, wasted a week.
You need to be more careful when reading the doc, maybe it will come in handy for someone

A
Alexander Karabanov, 2022-02-06
@karabanov

The user under which the application is trying to connect does not have rights to the database. Give it to him.

G
galaxy, 2022-02-07
@galaxy

The error is not postgres. The postgres user is usually a superuser, he cannot lack any rights (except for the only right to login).
Can you connect via psql (or any other client) to the database with this data?
Are there any problems with the network? Docker have access to 172.17.0.1:5432?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question