When I tried to connect to my database via SQLPLUS, I was getting the error "ORA-12170: TNS:Connect timeout occurred". I understood that the error could be due to firewall issue or database down or listener down or bad sqlnet.ora parm or even because of network issue. I did check on everything and found the firewall block caused the issue in my Windows server 2008 R2. Now I have to turn off the firewall that blocks the database port.
How to Turn off Firewall for DB Port:
Navigate to Control Panel --> All Control Panel Items --> Windows Firewall, click on Turn Windows Firewall on or off option and check the status of Firewall. If it is On, turn it Off and try connecting to database.
If it works, then the problem is due to firewall blockage. Now turn it On and go back to Windows Firewall page. Click on Advance settings option; create a new rule as shown in the snapshot below.
Follow the below screenshots to know the options to be followed while creating the rule to unblock DB Port.
Specify the DB port you have given while setting up the DB.
Whatever name and description give here will be reflected in the Inbound Rules page.
Now try connecting to the database. It worked for me and I hope this will help you as well. If you have any doubts, please feel free to comment on it.
If you find the error is because of slow network or system, then reconfigure one or all of the parameters SQLNET.INBOUND_CONNECT_TIMEOUT,SQLNET.SEND_TIMEOUT, SQLNET.RECV_TIMEOUT in sqlnet.ora to larger values. If a malicious client is suspected, use the address in sqlnet.log to identify the source and restrict access. Also verify that your hosts file has a DNS entry. Eg: 184.108.40.206
In Windows, the hosts file is located at win/system32/driver/etc/ and on UNIX, Linux, it is located in /etc/hosts.