Getting "dial tcp" error on EC2 instance after editing config.json


There is another question like this in the forum but it doesn’t answer my question, that one being a Docker question.
In my Amazon EC2 container, after configuring Postgres RDS connection in config.json, when I start the service, no matter what I do, it still tries to connect to Postgres on 127.1:5432 .

Steps to reproduce

I tried configuration, according to the guide, by editing config.json. Mine looks sorta like this:

cat /opt/mattermost/config/config.json | grep postgres
        "DriverName": "postgres",
        "DataSource": "",

I also tried the suggestion from that other Docker thread, like so, but this didn’t override it either.

export MM_USERNAME=postgres
export DB_PORT=5432
export MM_DBNAME=mattermost
export MM_SQLSETTINGS_DATASOURCE="postgres://$MM_USERNAME:$MM_PASSWORD@$DB_HOST:$DB_PORT/$MM_DBNAME?sslmode=disable&connect_timeout=10"
cd /opt/mattermost/
sudo -u mattermost ./bin/mattermost

Expected behavior

During initial start of the server, I just expected it to connect to my Postgres RDS instance.

Observed behavior

During startup, the log looks like this:

**ubuntu@ip-SECRET** : **/opt/mattermost** $ ./ 

,"msg":"Loaded system translations","for locale":"en","from locale":"/opt/mattermost/i18n/en.json"}
,"msg":"Server is initializing..."}
,"msg":"Pinging SQL","database":"master"}
,"msg":"Failed to ping DB","error":"dial tcp connect: connection refused","retrying in seconds":10}

Using server version 5.21.0

I discovered that I had to have postres:// in the front of the db url.

Now I am getting this error. Trying to figure it out:

"caller":"sqlstore/supplier.go:233","msg":"Failed to ping DB","error":"dial tcp i/o timeout","retrying in seconds":10

I got it to work. I switched to a MySQL RDS instance and it had no issue.

Thanks. I hope this helps someone else.