Answer the question
In order to leave comments, you need to log in
Why is accessing the local database from Docker not working?
I set everything up according to the answers from this article .
Here's what happened:
version: "3.7"
services:
redis:
container_name: redis
image: redis:6.2
restart: always
volumes:
- /data
ports:
- 6379:6379
app:
container_name: app
restart: always
image: bot:staging
env_file: .env
environment:
- DB_HOST=host.docker.internal
- REDIS_HOST=redis
ports:
- 3000:3000
extra_hosts:
host.docker.internal: host-gateway
external_links:
- redis
depends_on:
- redis
pg_isready -h 172.17.0.1 -p 5432 -U bot -d bot
res -> 172.17.0.1:5432 - accepting connections
Error: connect ETIMEDOUT 172.17.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1142:16) {
errno: -110,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '172.17.0.1',
port: 5432
}
Answer the question
In order to leave comments, you need to log in
If you enter the shell of the container with the application, will the database server be pinged?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question