Say you are trying to connect to server running on a remote machine you get a connection refused.
EX: Error massage says connection refused when trying to connect to https://192.168.1.1:8090/server/home
One of the reasons for this error can be your remote machine doesn't allow other IPs to connect through the particular port. In other words the the port which your trying connect is closed. To check that
1. Ping to the particular IP
Ex : In the terminal you can run
ping 192.168.1.1
If it is successful;
2. Telnet and see whether you can connect to the port
Ex: telnet 192.168.1.1 8090
3. If you get a connection refused for above command then try below command.
sudo iptables -F INPUT
** Above command flushes all rules and open all ports for the logged it session.
4. Then when you telnet to the port and if you successfully get connected with the port the issue is the particular port is closed.
5. To open the particular port you need to add it to /etc/sysconfig/iptables.
EX: -A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT
Note : When adding make sure you add it before REJECT rules.
6. After adding you run
EX: Error massage says connection refused when trying to connect to https://192.168.1.1:8090/server/home
One of the reasons for this error can be your remote machine doesn't allow other IPs to connect through the particular port. In other words the the port which your trying connect is closed. To check that
1. Ping to the particular IP
Ex : In the terminal you can run
ping 192.168.1.1
If it is successful;
2. Telnet and see whether you can connect to the port
Ex: telnet 192.168.1.1 8090
3. If you get a connection refused for above command then try below command.
sudo iptables -F INPUT
** Above command flushes all rules and open all ports for the logged it session.
4. Then when you telnet to the port and if you successfully get connected with the port the issue is the particular port is closed.
5. To open the particular port you need to add it to /etc/sysconfig/iptables.
EX: -A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT
Note : When adding make sure you add it before REJECT rules.
6. After adding you run
sudo service iptables restart
Now you have opened the particular port and other machine should be successfully connect using that port.
No comments:
Post a Comment