MySQL IPv6 connection issue

Hi!

I just tried to install crowdsec which seems to be a really interesting software, but I encountered a problem with the connection between my crowdsec agent and my database.
I setup the config.yml file as follow:

db_config:
  log_level: info
  type: sqlite
  #db_path: /var/lib/crowdsec/data/crowdsec.db
  user: {my_user}
  password: {my_password}
  db_name: {my_db}
  host: 2a0b:c489:03f3::0:f4
  #port: 3306

But I have the following error:
FATA[21-12-2021 09:14:24 PM] unable to create new database client: failed creating schema resources: dial tcp [2a0b:c489:03f3::0:f4:0]:3306: connect: no route to host
As you can see, crowdsec added a :0 at the end of my IPv6 address. I don’t know why this was added but it blocks the connection because that’s not the right IP address…
PS: don’t try to ping the IP address, I replaced mine by a random one.

If somebody already had this problem or know how to solve it, I’m interested.

Thank!

Hello @Lourys,

Can you try to enclose the IP in square brackets in the config file ? (something like "[2a0b:c489:03f3::0:f4]", with the double quotes or the YAML parser will throw an error).

The 0 added at the end of the IP is the port number (as you didn’t specify it in the configuration, it uses a default value, but I’d recommend setting it explicitly, I’m not sure how crowdsec will behave if not set).

This is because internally we concatenate the IP and the port using : as a separator, but this means that the IP must be in squared brackets to allow the mysql driver to correctly parse the IP and the port.

We will update the documentation to make this more explicit.

Thank you @blotus it worked!