Postgresql recusando conexão TCP / IP após reiniciar o ubuntu

0

Esse aqui me deixa perplexo.

Eu reiniciei meu servidor ubuntu e agora tento conectar-me ao pgadmin e recebo o seguinte:

could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "<ip.address>" and accepting
TCP/IP connections on port 5432?

No meu arquivo postgresql.conf

listen_addresses = '*'

No meu pg_hba.conf

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database superuser can access the database using some other method.
# Noninteractive access to all databases is required during automatic
# maintenance (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5



host    all     all     129.125.179.201/32      trust
host    all     all     86.81.139.21/24         trust

Eu adicionei a seguinte linha ao final

host    all     all     0.0.0.0/0       md5

Ainda não é possível conectar

Eu reiniciei o postgresql após cada alteração.

Eu posso logar no postgresql através da linha de comando via shh.

Estou sem ideias!

Editar

iptables

sudo iptables -S
-P INPUT ACCEPT
-P FORWARD DROP
-P OUTPUT ACCEPT
-N DOCKER
-N DOCKER-ISOLATION
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j DROP
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -j DROP
-A OUTPUT -j ACCEPT
-A DOCKER-ISOLATION -j RETURN

Resultados do Netstat

netstat -lt4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:mysql         *:*                     LISTEN
tcp        0      0 *:8787                  *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:postgresql            *:*                     LISTEN

iptables-save

sudo iptables-save
# Generated by iptables-save v1.6.0 on Sat Sep 23 18:23:36 2017
*nat
:PREROUTING ACCEPT [48958:12725477]
:INPUT ACCEPT [2847:159736]
:OUTPUT ACCEPT [70:6309]
:POSTROUTING ACCEPT [70:6309]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A DOCKER -i docker0 -j RETURN
COMMIT
# Completed on Sat Sep 23 18:23:36 2017
# Generated by iptables-save v1.6.0 on Sat Sep 23 18:23:36 2017
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:DOCKER - [0:0]
:DOCKER-ISOLATION - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j DROP
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o docker0 -j DOCKER
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -j DROP
-A OUTPUT -j ACCEPT
-A DOCKER-ISOLATION -j RETURN
COMMIT
# Completed on Sat Sep 23 18:23:36 2017
    
por Gary Nobles 23.09.2017 / 15:58

1 resposta

0

Eu acho que o problema não está relacionado com a autorização (por exemplo, pg_hba.conf) pois seu erro sugere porta inacessível. Tente apontar os parâmetros de conexão que puder. Também tente conectar usando alguma ferramenta simples como o psql (com todos os parâmetros de conexão fornecidos, por exemplo. -H localhost -U user -W -p 5432, etc.) Isso deve lhe dar alguma dica sobre o que está acontecendo e onde procurar mais .

Especialmente, dê a ele -h localhost, já que de outra forma ele usaria o socket unix local do TCP

EDIT: Você tem certeza de que esta é uma boa regra de iptable: -A INPUT -d 127.0.0.0/8 -j REJEITAR --rejeitar-com icmp-port-inacessível Não sou especialista aqui, mas tente remover esta entrada temporariamente e conecte-se novamente. Mesma preocupação sobre: -A INPUT -j DROP

EDIT2: Se nada funcionar, por favor despeje todos os iptables por "iptables-save" insteed de "iptables -S". "iptables-save" faz o dump de todas as tabelas disponíveis (eg. filter, nat, etc.). Mais informações no manual

    
por Astinus Eberhard 23.09.2017 / 17:08