RUNNING RASA WITH DOCKER DOES NOT WORK

Hi all, I am trying to run rasa using docker-composse that has three services: Rasa, Django custom actions server and the database.

However, I have the following error:

Rasa.core.tracker_store - Could not create tables: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host “127.0.0.1” and accepting TCP/IP connections on port 5432?

The same error raised when the web services for my action server is trying to connect to the database.

Here is the content of my docker-compose file:

version: '3.0'
services:
  postgres:
    image: postgres:latest
    volumes:
      - pg-db-data:/var/lib/postgresql/data
  rasa:
    image: rasa/rasa:latest-full
    ports:
      - 5005:5005
    volumes:
      - .:/app
    command: >
      run --model bot/models/20190926-122649.tar.gz --endpoints bot/endpoints.yml --credentials bot/credentials.yml --enable-api --debug
  web:
    volumes:
      - .:/app
    build: .
    command: python manage.py runserver 
    ports:
      - "8000:8000"
    depends_on:
      - postgres
volumes:
  pg-db-data:

What I suspect is that it is an environment error. I tried to change the port from “127.0.01” to “0.0.0.0” where the postgres service indicated rasa is running, but still nothing. I tried many other things, but sill not working Is someone, have a guess of how I can solve that ?

Thanks in advance.

Hi @Rogers_ntr not sure if you’re still having this issue (sorry for the late response), but I think looking at the docker-compose file for Rasa X may help you, to see how to setup postgres properly: Deploy to a Server

Thanks @akelad for the answer. The issue is still there. I still encounter the problem. I have taken a close look to the Rasa X example, but still get the same error actually after many trials.

This might be worth a shot…

Any code you have running in the docker containers will be able to resolve the name of each service in your docker-compose file to the ip address assigned to the docker container running that service. The docker containers are usually assigned an ip address in the 172.xxx.yyy.zzz block, iirc.

So, in your action server, instead of trying to connect to 127.0.0.1 or 0.0.0.0 - try connecting to postgres instead - just replace the ip address with the string “postgres”, because that’s what you called your db service in the docker compose file. The docker dns resolver will then map this to the actual ip address the postgres service container has been assigned, and you should be able to connect.

Hope that helps.

hm yeah could you share your tracker store definition in the endpoints file actually?

@akelad @netcarver Thanks for the replies. Here is the tracker store:

tracker_store:
  type: SQL
  dialect: "postgresql"
  port: 5432
  db: 'conversation'
  username: 'rogers'
  password: '<a_password>'
  url: 'postgres

I tried to change the username to postgres string, but the same error still occured. Any clue ?

@Rogers_ntr sorry for never getting back to you - have you since resolved this?