[Solved] Initial setup problems with connection to database

I’m following the instructions here. I’m on ubuntu 14.04 server, and it was a fresh install with nothing on it.

When I got to step 8 under “Setup Mattermost Server” and run ./platform I get an error:

[CRIT] Failed to ping db err:dial tcp connection refused
panic: Failed to open sql connection dial tcp connection refused

goroutine 1 [running]:
github.com/mattermost/platform/store.setupConnection(0xb4ddf0, 0x6, 0xc20800bc88, 0x8, 0xc208054120, 0x5d, 0xa, 0xa, 0x4e0500, 0x95d960)
    /home/travis/gopath/src/github.com/mattermost/platform/store/sql_store.go:146 +0x581
github.com/mattermost/platform/store.NewSqlStore(0x0, 0x0)
    /home/travis/gopath/src/github.com/mattermost/platform/store/sql_store.go:52 +0x106
    /home/travis/gopath/src/github.com/mattermost/platform/api/server.go:33 +0x15a
    /home/travis/gopath/src/github.com/mattermost/platform/mattermost.go:55 +0x4d8

goroutine 6 [syscall]:
    /usr/local/go/src/os/signal/signal_unix.go:21 +0x1f
created by os/signal.init·1
    /usr/local/go/src/os/signal/signal_unix.go:27 +0x35

goroutine 7 [chan receive]:
code.google.com/p/log4go.ConsoleLogWriter.run(0xc208054240, 0x7f4746a23ff0, 0xc20802c008)
    /home/travis/gopath/src/github.com/mattermost/platform/Godeps/_workspace/src/code.google.com/p/log4go/termlog.go:27 +0x7a
created by code.google.com/p/log4go.NewConsoleLogWriter
    /home/travis/gopath/src/github.com/mattermost/platform/Godeps/_workspace/src/code.google.com/p/log4go/termlog.go:19 +0x6b

goroutine 8 [select]:
    /home/travis/gopath/src/github.com/mattermost/platform/Godeps/_workspace/src/code.google.com/p/log4go/filelog.go:84 +0xa53
created by code.google.com/p/log4go.NewFileLogWriter
    /home/travis/gopath/src/github.com/mattermost/platform/Godeps/_workspace/src/code.google.com/p/log4go/filelog.go:116 +0x3da

goroutine 9 [chan receive]:
    /usr/local/go/src/database/sql/sql.go:589 +0x4c
created by database/sql.Open
    /usr/local/go/src/database/sql/sql.go:452 +0x31c

This problem is almost identical to this one, but they just say they were able to fix that first problem, and never said how.

my 5432 port is open;

sudo netstat -tulpn

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0    *               LISTEN      922/sshd        
tcp        0      0*               LISTEN      1028/postgres   
tcp        0      0    *               LISTEN      1121/nginx      
tcp6       0      0 :::22                   :::*                    LISTEN      922/sshd        
tcp6       0      0 ::1:5432                :::*                    LISTEN      1028/postgres   

Any ideas?

Is the db on a different box? can you connect via the psql command?

maybe something like http://www.thegeekstuff.com/2014/02/enable-remote-postgresql-connection/

Hi, thanks for the response. I’m setting up Mattermost all on a single machine, including the db. From the instructions, I set up a postgres user on my machine, and I am able to run psql and connect and view the database.

I am a postgres noob, so I’ll link my pg_hba.conf just to make sure I don’t have something obviously wrong there.

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all               md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Can you past in the db connection string in config.json minus the username/pwd ? It looks like it’s trying to connect to I think you can probably have instead. What psql cmd did you run?

Well that was simple enough. I appreciate the help. If I change it to it works fine. I tried that earlier, but I think I tried it when I had another setting incorrect. Thanks again!

I ran into the similar issue
Connection string:

"DataSource": "mmuser:mmPassword@tcp(localhost:3306)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"

I was getting below error on command sudo -u mattermost ./bin/mattermost

MySql was running on a different port on my system, it was running on port 6606 and not on 3306.

You can run the below commands to check the MySql port

cd /etc/mysql/mysql.conf.d
sudo nano mysqld.cnf

in the file mysqld.cnf you can look at the value for port

Correct connection string that worked for me then

"DataSource": "mmuser:mmPassword@tcp(localhost:6606)/mattermost?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s"