[Solved] Failed to ping db err

I am trying to set up a production environment within the Google Compute Platform. I’ve created a Ubuntu VM for the database and was able to get the PostgreSQL db up and running. I created the second Ubuntu VM, installed the Mattermost package and updated the config.json file, but I keep running into this error:

[10/28/15 16:00:40] [INFO] Current version is 1.1.0 (2920/Wed Oct 14 19:29:00 UTC 2015/4ad9e0673ca8950597a290f10db1
0475b18b67cc)
[10/28/15 16:00:40] [INFO] Current working directory is /home/rorysmith/mattermost/bin
[10/28/15 16:00:40] [INFO] Loaded config file from /home/rorysmith/mattermost/config/config.json
[10/28/15 16:00:40] [INFO] Server is initializing...
[10/28/15 16:00:40] [INFO] Pinging sql master database
[10/28/15 16:00:40] [CRIT] Failed to ping db err:dial tcp 10.240.0.2:5432: connection refused
panic: Failed to open sql connection dial tcp 10.240.0.2:5432: connection refused

I’ve set up firewall rules to allow tcp traffic on ports 80, 8065 and 5432. Any other suggestions?

I was able to connect when I use the same server for both the DB and Mattermost using the address 127.0.0.1:5432. So I’m assuming I don’t have the DB server configured properly to allow external traffic on port 5432.

Still working with a single server, I am able to get to the last step of setting up the Mattermost Server section. The start command

sudo start mattermost

returns

mattermost start/running, process 15797

but if I try to stop it I get

stop: Unknown instance: 

and I get a “failed to connect to xx.xxx.x.x port 8065: Connection refused” error when I try the curl check. Just for reference, this is what I’m seeing when I test the Mattermost server:

[10/28/15 18:46:37] [INFO] Current version is 1.1.0 (2920/Wed Oct 14 19:29:00 UTC 2015/4ad9e0673ca8950597a290f10db10475b18b67cc)
[10/28/15 18:46:37] [INFO] Current working directory is /home/ubuntu/mattermost/bin
[10/28/15 18:46:37] [INFO] Loaded config file from /home/ubuntu/mattermost/config/config.json
[10/28/15 18:46:37] [INFO] Server is initializing...
[10/28/15 18:46:37] [INFO] Pinging sql master database
[10/28/15 18:46:37] [INFO] Pinging sql replica-0 database
[10/28/15 18:46:37] [DEBG] Initializing user api routes
[10/28/15 18:46:37] [DEBG] Initializing team api routes
[10/28/15 18:46:37] [DEBG] Initializing channel api routes
[10/28/15 18:46:37] [DEBG] Initializing post api routes
[10/28/15 18:46:37] [DEBG] Initializing web socket api routes
[10/28/15 18:46:37] [DEBG] Initializing file api routes
[10/28/15 18:46:37] [DEBG] Initializing command api routes
[10/28/15 18:46:37] [DEBG] Initializing admin api routes
[10/28/15 18:46:37] [DEBG] Initializing oauth api routes
[10/28/15 18:46:37] [DEBG] Initializing webhook api routes
[10/28/15 18:46:37] [DEBG] Parsing server templates at /home/ubuntu/mattermost/api/templates/
[10/28/15 18:46:37] [DEBG] Initializing web routes
[10/28/15 18:46:37] [DEBG] Using static directory at /home/ubuntu/mattermost/web/static/
[10/28/15 18:46:37] [DEBG] Parsing templates at /home/ubuntu/mattermost/web/templates/
[10/28/15 18:46:37] [INFO] Starting Server...
[10/28/15 18:46:37] [INFO] Server is listening on :8065
[10/28/15 18:46:37] [INFO] RateLimiter is enabled

I was able to work through these issues (albeit doing the single server installation). I made it through the Nginx setup (but not through the SSL portion) and everything seems fine except for the mapping from 8065 to 80. When I try to curl http://localhost I get “failed to connect to port 80: connection refused” error.

I can access the instance from the example.domain:8065 address though.

I’m guessing maybe nginx isn’t configured correctly. I think you might be missing the below in the nginx config

server {
       listen         80;

and

 proxy_pass http://localhost:8065;

see https://github.com/mattermost/platform/blob/master/doc/install/Production-Ubuntu.md

Ah, I did use the example config in that install guide, but it doesn’t include the listen parameter at all. I just added it and restarted the nginx service but still a no go.

For reference, this is how my config file looks:

http {     
  server {
        listen 80;
        server_name example.domain.com;
        location / {
            client_max_body_size 50M;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header   X-Frame-Options   SAMEORIGIN;
            proxy_pass http://localhost:8065;
        }
    }
}

Well, I originally had it without the http and after some digging realized I didn’t need that. Not sure what I did differently this time, but deleting the old mattermost file and link and recreating and linking again did the trick!

See here: