Cannot connect to PostgreSQL Remotely on Amazon EC2 instance using PgAdmin

前端 未结 3 1623
故里飘歌
故里飘歌 2021-02-13 05:30

I have a micro free tier RHEL 6 instance running and have postgresql 9.2 installed using the yum instructions here: http://yum.pgrpms.org/howtoyum.php

And I am able conn

3条回答
  •  无人及你
    2021-02-13 05:57

    Do you have a firewall blocking port 5432? A quick nmap shows that it is being filtered.

    nmap -Pnv -p 5432 ec2-54-251-188-3.ap-southeast-1.compute.amazonaws.com
    
    Starting Nmap 6.00 ( http://nmap.org ) at 2013-07-21 11:05 PDT
    Nmap scan report for ec2-54-251-188-3.ap-southeast-1.compute.amazonaws.com (54.251.188.3)
    Host is up (0.19s latency).
    PORT     STATE    SERVICE
    5432/tcp filtered postgresql
    

    What does the iptables on your EC2 show for port 5432?

    iptables -nvL
    

    [after OP added more details]

    Netstat shows that it is listening, but the firewall output doesn't look like the 5432 port is open (I confess to not being much of a network guy). Referring to some of my notes from previous installs, you might need to open up EC2 port 5432 to your IP.

    To allow input firewall access, replace YOUR-REMOTE-IP with the IP you are connecting from:

    iptables -A INPUT -p tcp -s YOUR-REMOTE-IP --sport 1024:65535 -d 54.251.188.3 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
    iptables -A OUTPUT -p tcp -s 54.251.188.3 --sport 5432 -d YOUR-REMOTE-IP --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
    

    --outbound access

    iptables -A OUTPUT -p tcp -s 54.251.188.3 --sport 1024:65535 -d 0/0 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
    iptables -A INPUT -p tcp -s 0/0 --sport 5432 -d 54.251.188.3 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
    

    What does iptables -nvL list after that. Can you connect?

提交回复
热议问题