ECONNREFUSED when connecting to MariaDB

I’m trying to generate an energy report. For that goal I want to query on the database in my case MariaDB.

In Node-RED I’m using the “node-red-contrib-stackhero-mysql” node. But I have also tried the “node-red-node-mysql” node.

The crazy thing is that it works but on some moments not. I have scheduled the task (of generating an energy overview mail) at 00:00. Tonight it hadn’t been running. But I have started it manually with the inject node and it works.

I get a lot of this errors in the Node-RED log:

12 Jan 15:18:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:18:41 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:19:01 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:19:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:19:41 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:20:01 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:20:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:20:41 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:21:01 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:21:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:21:41 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:22:01 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:22:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:22:41 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:23:01 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306
12 Jan 15:23:21 - [error] [MySQLdatabase:HomeAssistant] Error: connect ECONNREFUSED ::1:3306

From Home Assistant recorder I use this connectionstring:

mariadb_url: 'mysql://homeassistant:xxxxxxxxxxxxxx@core-mariadb/homeassistant?charset=utf8mb4'

In Node-RED I have this configuration:

image

In phpMyAdmin I have those rights:

Do I have to do something special? Creating special user or do some configuration?

Hi the same issue. Sometimes connect for a while and suddenly connection refused. I will appreciate any help. Thanks a lot.

At my side it works now perfect. What have I done?

I completely removed the “node-red-node-mysql” and “node-red-contrib-stackhero-mysql” nodes.

Then I installed only the “node-red-node-mysql” and connecting with:

host: core-mariadb
port: 3306
user: homeassistant
password: …
database: homeassistant
timezone: leave it empty
charset: utf8mb4

1 Like

Hi Martin, thanks a lot. Today I tested with “node-red-contrib-mysql-config” and everything started to work. Thank you for your feedback, I will test it.

Hi. This just helped me too. I was setting the host to localhost. Thanks!

Thanks this helped me