Amazon Linux 2 - EC2 PostgreSQL

Solution 1:

**You'll have to add your user to pg_hba.conf and specify the network cidr in your entry.

The entries follow this format:

TYPE DATABASE USER ADDRESS METHOD

Here's an example for a local connection using md5 (you have to specify the loopback address as a /32):

local   myuser        all             127.0.0.1/32         md5

**Here's an example allowing a connection on the same class A network (you can always expand or restrict the CIDR more appropriately depending on your needs for the hosts that will be accessing your postgres server):**
host    all             myuser       10.10.0.0/24          md5

Then reload postgres: systemctl reload postgresql

After that, you should then be able to log in.