Problem connecting mysql with rasa x using docker-compose in custom actions

Hello @nik202 Actually am not using any image

@nik202 I have in my linux mysql machine install locally in which there is a rasa_bot database. When a user talks to the bot, the bot invokes the custom action that is correct for the given intention and searches the rasa database for the answer. This is possible thanks to a configuration file located in the actions folder in which we provide connection information (those of mysql-connector) without docker-compose this works however with docker compose, the connection to the database does not work @nik202 is it possible to connect my local database to the docker environment? on the other hand I do not know if it is necessary to completely run rasa, rasa-sdk and mysql in docker-compose environment

this is the configuration of the dbfile

import mysql.connector
import traceback

def getData(query:str):
     @query: sql query that needs to be executed.
     returns the data being executed in "List" format


        # Setup the connection.
        # Pass your database details here
        mydb = mysql.connector.connect(

        # set up the cursor to execute the query
        cursor = mydb.cursor()

        # fetch all rows from the last executed statement using `fetchall method`.
        results = cursor.fetchall()
        return results
        print("Error occured while connecting to database or fetching data from database. Error Trace: {}".format(traceback.format_exc()))
        return []


@M_R_LY means your rasa is running on docker and mysql database on local machine right and you want to connect both?

@nik202 yeah exactly Or if there is a good practice am in :pray: @nik202

@M_R_LY I hope you are aware of the tracker store? try update the endpoints.yml for your current database

   type: SQL
   dialect: "mysql+pymysql"  # the dialect used to interact with the db
   url: "localhost"  # (optional) host of the sql db, e.g. "localhost"
   db: "rasa"  # path to your db
   username: "root"  # username used for authentication
   password: "root"  # password used for authentication

hello @nik202
Actually, this is the section part in the endpoints.yml when you deploy rasa-x via docker compose they are using postgresql image

@nik202 I dont want to store conversation but just retrieve some informations from the local database i have on my actions file somlething like this :

@M_R_LY Please be clear what you using MySQL or Postgres, as you shown in the code you using 3306 which is the port of Mysql and on the other hand, Postgres run on port 5432. I hope you understand my point.

Hi @nik202 i understand your confusion, that configuration in the endpoints.yml has been automatically generated by the rasa-x docker compose installation and its using Postgres for the tracker store. Which have nothing to do with my little configuration that i have in my actions file in order to search for some informations in my database (the second image in my last post). @nik202 there is a part In my my custom actions where i need to connect to my mysql database, search for some data and display it

@M_R_LY commented this tracker store and used your ? @M_R_LY please share me the clean and final code of your docker, custom action and endpoints.

@M_R_LY No update? huh did you able to solve this?

@nik202 hello, not yet. Am travelling right now so soon i get back home i will post the files @nik202


I would suggest you containerize your database and bundle it with existing rasa docker set-up. This tutorial guides you on how to containerize your DB and bundle it with an app.

Hello @nik202 sorry for the late i have tryied several configurations but its still the same pb i share with you my :

actions file : (3.0 KB)

the endpoints : endpoints.yml (782 Bytes)

docker-compose.override file : docker-compose.override.yml (448 Bytes)

the docker file : Dockerfile (642 Bytes)

for the getData fonction in the actions file, here is the code


@M_R_LY I can’t see your rasa or rasa-x only rasa-sdk in docker file? How you managing the rasa? Are you sure you able to run rasa using docker or docker-compose file?

hi @nik202 my bad i didnt attach the docker-compose file here it is docker-compose.yml (5.1 KB)

@siriusraja if it can help too

hi @nik202 and , i managed to solve the problem.

i just had to allow my user to connect from my ip (the container ip) in my local database

GRANT ALL ON database_name.* to 'database_username'@'' IDENTIFIED BY 'database_password';


you must specify this too the ip of your database

@nik202 I managed to run also multiple bot in the same server just follow the download step and for the configuration , change the port number for the

RASA_X_HOST (by default 5002)


RASA_USER_APP (by default 5055)

and the

RASA_PRODUCTION_HOST (by default 5005)

for the second bot (or the others) Change also the nginx service port

  - "8080:8080"   (by default for the first bot ) to "8081:8080"   (for the second bot)
      - "443:8443"   (by default for the first bot) to "444:8443" (for the second bot)

and in the browser specify the port for both bot

@nik202 maybe i will do a thread if i got some time Thanks for the help

@M_R_LY Many congratulations :+1: and thanks for sharing the solution for other. Good Luck!

1 Like

@M_R_LY Are your bot is running in the Production mode (Rasa-X)?

Yes! raxa-x deployed with docker compose and action server @nik202

hello @nik202 here is an article that i have wrote for rasa deployement with docker-compose and how to connect custom action to mysql