Useful shortcuts for vi editor

Friday, 13 July 2018

How to solve remote connection error cause of iptables/firewalld service?

Case
Machine A(192.168.1.2) wants to connect on Machine B(192.168.1.5) by database port.

Action
In Machine A;
# su - postgres
$ psql -h 192.168.1.5 -d alper -U alper -p 5433

Error
psql: could not connect to server: No route to host
        Is the server running on host "192.168.1.5" and accepting
        TCP/IP connections on port 5433?

Solution
In Machine B;
For iptables service:
# iptables -I INPUT -p tcp --dport 5433 -j ACCEPT
# iptables-save

For firewalld service:
# firewall-cmd --zone=public --add-port=5433/tcp --permanent
# firewall-cmd --reload

Check
In Machine A;
nc -vz 192.168.1.5 5433
Ncat: Connected to 192.168.1.5:5433