Answer the question
In order to leave comments, you need to log in
Docker postgres node error error: role "username" does not exist?
Hello!
I ran into a problem that when I run a node through docker (which I'm new to), I can't access the database.
I've searched everywhere and I don't understand what's going on...
//docker-compose.yml
version: "3"
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: username
volumes:
- './pgdata:/usr/src/data'
ports:
- '5432:5432'
server:
image: node:alpine
command: sh -c "npm install && npm run dev"
volumes:
- ./backend:/usr/src/client
working_dir: /usr/src/client
ports:
- "8080:8080"
environment:
HOST: 127.0.0.1
restart: always
tty: true
//подключение к базе из ноды
const { Pool } = require('pg');
const pool = new Pool({
max: 20,
connectionString: 'postgres://username:[email protected]:5432/mydatabase',
idleTimeoutMillis: 30000
});
module.exports = pool
Answer the question
In order to leave comments, you need to log in
if presenting for a license is not scary - implement it on a stealth base, it’s business
Well, what is not clear? The database does not contain the role with which you want to connect. Create it, issue the necessary rights.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question