Open PostgreSQL

Determine if TCP port 5432 for PostgreSQL is open to the public

While some ports such as HTTP and HTTPS are required to be open to the public to function properly, more sensitive services such as PostgreSQL should be restricted to known IP addresses.

Follow the appropriate remediation steps below to resolve the issue.

  1. Log into the AWS Management Console.

  2. Select the “Services” option and search for EC2. Step

  3. Scroll down the left navigation panel and choose “Security Group” under “Network & Security”.Step

  4. Select the “EC2 Security Group” that needs to be verified. Step

  5. Scroll down the bottom panel and choose “Inbound”. Verify the value for “Source” column for “PostgreSQL” under “Type” for port “5432” and if any rule have value set to “” or “::/0 " then the selected “Security Group” has “TCP” port for “PostgreSQL” open to the public.Step

  6. Repeat steps number 2 - 5 to verify other “Security Groups” in the selected AWS region.

  7. Navigate to “Security Groups” under “Network & Security” and select the “Security Group” that needs to modify to restrict the access of “TCP” port 5432 for “PostgreSQL” to specific ip address. Step

  8. Scroll down the page and select the “Inbound” and click on the “Edit” button. Step

  9. In the “Edit inbound rules” tab select either the “MyIP” or “Custom” from the “Source” column.Step

  10. In the “Edit inbound rules” tab select the “MyIP” from the “Source” column to allow “PostgreSQL” inbound traffic only from specific IP address.Step

  11. In the “Edit inbound rules” tab select the “Custom” from the “Source” column as per the requirements for “PostgreSQL” and specify static IP/Elastic IP address along with “Description” for the “Security Group” rule. Step

  12. Click on the “Save” button to make the necessary changes. Step

  13. Repeat steps number 7 - 12 to restrict TCP port 5432 for “PostgreSQL” to known IP address.