Skip to content

Error: P1001: Can't reach database server at postgres:5432 #2381

@giovvv

Description

@giovvv

Welcome!

  • Yes, I have searched for similar issues on GitHub and found none.

What did you do?

I have installed evolution API using docker, following the instructions on the site. I have installed via docker composer first redis and postgresql, then evolution_api.

When the evolution API is started (via docker compose up -d), it fails.

Following are the configuration files.

evolution_api docker-compose.yml:

version: '3.9'
services:
  evolution-api:
    container_name: evolution_api
    image: atendai/evolution-api:v2.1.1
    restart: always
    ports:
      - "8080:8080"
    env_file:
      - .env
    volumes:
      - evolution_instances:/evolution/instances

volumes:
  evolution_instances:

evolution_api .env:

AUTHENTICATION_API_KEY=a_random_string

########### REDIS

# Enable Redis cache
CACHE_REDIS_ENABLED=true

# Redis connection URI
CACHE_REDIS_URI=redis://localhost:6379/6

# Prefix to differentiate data from different installations using the same Redis
CACHE_REDIS_PREFIX_KEY=evolution

# Enable to save connection information in Redis instead of the database
CACHE_REDIS_SAVE_INSTANCES=false

# Enable local cache
CACHE_LOCAL_ENABLED=false


########### DATABASE

# Enable the use of the database
DATABASE_ENABLED=true

# Choose the database provider: postgresql or mysql
DATABASE_PROVIDER=postgresql

# Database connection URI
DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public'

# Client name for the database connection
DATABASE_CONNECTION_CLIENT_NAME=evolution_exchange

# Choose the data you want to save in the application database
DATABASE_SAVE_DATA_INSTANCE=true
DATABASE_SAVE_DATA_NEW_MESSAGE=true
DATABASE_SAVE_MESSAGE_UPDATE=true
DATABASE_SAVE_DATA_CONTACTS=true

postgresql docker-compose.yml:

version: '3.3'

services:
  postgres:
    container_name: postgres
    image: postgres:15
    networks:
      - evolution-net
    command: ["postgres", "-c", "max_connections=1000"]
    restart: always
    ports:
      - 5432:5432
    environment:
      - POSTGRES_PASSWORD=PASSWORD
    volumes:
      - postgres_data:/var/lib/postgresql/data
    expose:
      - 5432

  pgadmin:
    image: dpage/pgadmin4:latest
    networks:
      - evolution-net
    environment:
      - PGADMIN_DEFAULT_EMAIL=EMAIL
      - PGADMIN_DEFAULT_PASSWORD=PASSWORD  
    volumes:
      - pgadmin_data:/var/lib/pgadmin
    ports:
      - 4000:80
    links:
      - postgres


volumes:
  postgres_data:
  pgadmin_data:


networks:
  evolution-net:
    name: evolution-net
    driver: bridge

these are the files verbatim which I am using, i don't know if i should substitute e.g. PASSWORD/user/pass with something else, the documentation says nothing about that.

What did you expect?

It should start.

What did you observe instead of what you expected?

Redis and postgresql appears to work, but evolution_api does not, going into an endless restart loop.

docker logs evolution_api shows:

Error: P1001: Can't reach database server at `postgres:5432`

Please make sure your database server is running at `postgres:5432`.
Error executing command: rm -rf ./prisma/migrations && cp -r ./prisma/postgresql-migrations ./prisma/migrations && npx prisma migrate deploy --schema ./prisma/postgresql-schema.prisma

Screenshots/Videos

No response

Which version of the API are you using?

2.1.1

What is your environment?

Linux

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions