Skip to content

Instantly share code, notes, and snippets.

@skplunkerin
Last active November 4, 2017 16:33
Show Gist options
  • Save skplunkerin/3e177e123dc066f8314e440f259a1a86 to your computer and use it in GitHub Desktop.
Save skplunkerin/3e177e123dc066f8314e440f259a1a86 to your computer and use it in GitHub Desktop.
EC2 server psql postgres postgresql external IP access

https://bosnadev.com/2015/12/15/allow-remote-connections-postgresql-database-server/

First, make sure your AWS EC2 security group allows PostgreSQL external access:

  • Type: PostgreSQL
  • Protocol: TCP
  • Port Range: 5432
  • Source: Custom 0.0.0.0/0

Edit the following files:

First, allow more than just localhost to connect to the DB

/etc/postgresql/9.4/main/postgresql.conf

listen_addresses = '*'

Then, pick what IP's have access

/etc/postgresql/9.4/main/pg_hba.conf (replace xx.xx.xx.xx with your IP address, or add 0.0.0.0/0 md5 to allow all connections)

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             XX.XX.XX.XX/32          trust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment