We're Hiring!

Mattermost, Inc.

Error while connect mysql DB server from mattermost Server

root@ip-10-0-0-121:/opt/mattermost# sudo -u mattermost ./bin/mattermost
~
{“level”:“info”,“ts”:1610895608.3293824,“caller”:“utils/i18n.go:83”,“msg”:“Loaded system translations”,“for locale”:“en”,“from locale”:"/opt/mattermost/i18n/en.json"}
{“level”:“info”,“ts”:1610895608.3298504,“caller”:“app/server_app_adapters.go:58”,“msg”:“Server is initializing…”}
{“level”:“info”,“ts”:1610895608.3336732,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL”,“database”:“master”}
{“level”:“error”,“ts”:1610895608.3370194,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB”,“error”:“dial tcp 10.0.1.107:3306: connect: connection refused”,“retrying in seconds”:10}
{“level”:“info”,“ts”:1610895618.337415,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL”,“database”:“master”}
{“level”:“error”,“ts”:1610895618.3381448,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB”,“error”:“dial tcp 10.0.1.107:3306: connect: connection refused”,“retrying in seconds”:10}
{“level”:“info”,“ts”:1610895628.3384464,“caller”:“sqlstore/supplier.go:224”,“msg”:“Pinging SQL”,“database”:“master”}
{“level”:“error”,“ts”:1610895628.3392,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB”,“error”:“dial tcp 10.0.1.107:3306: connect: connection refused”,“retrying in seconds”:10}
^C
root@ip-10-0-0-121:/opt/mattermost# telnet 10.0.1.107 3306
Trying 10.0.1.107…
telnet: Unable to connect to remote host: Connection refused
root@ip-10-0-0-121:/opt/mattermost# ^C
root@ip-10-0-0-121:/opt/mattermost# 0,0-1 All
root@ip-10-0-0-121:/opt/mattermost# {“level”:“error”,“ts”:1610895628.3392,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB”,“error”:“dial tcp 10.0.1.107:3306: connect: connection refused”,“retrying in seconds”:10}

Hello, @roupadhy

The error that we are getting here indicates that the Mattermost Server is unable to reach out and communicate with the MySQL database that you have configured:

{“level”:“error”,“ts”:1610895618.3381448,“caller”:“sqlstore/supplier.go:236”,“msg”:“Failed to ping DB”,“error”:“dial tcp 10.0.1.107:3306: connect: connection refused”,“retrying in seconds”:10}

May I know if you have any firewall configured that might potentially block the connection from either of the servers? If yes, can you please whitelist the IP address(es) accordingly to allow the servers to communicate with each other?

Since the result of telnet shows that Connection refused, that will be one of the first things that I would recommend you to check.

Hello @ahmaddanial
yes I was trying to connect my mattermost EC2 ubuntu (public subnet) instance to my private subnet mysql instance database. I had allowed all security ports from security groups of instances but didn’t worked but after allowing the ports in both instances using “sudo ufw allow” and changing config file of mysql to bind address 0.0.0.0:3306 it’s now working fine.

1 Like

Hi, @roupadhy

Got it. Thanks for the explanation especially and confirming that it is working well on your end now!

Let me know if you have any other concerns about Mattermost and I’ll be happy to discuss about it in another topic.

1 Like