Solving "ORA-12170: TNS Connect Timeout Occurred" Error

Oracle databases are widely used around the world, and like any other software, they can run into issues. One such issue is the ORA-12170 error, which occurs when a client is unable to establish a connection to the Oracle database server within the specified time period. In this guide, we will provide a comprehensive explanation and step-by-step solution to resolve the ORA-12170 error.

Table of Contents

Understanding the ORA-12170 Error

The ORA-12170 error occurs when a client fails to establish a connection to the Oracle database server within the specified time period. The error message looks like this:

ORA-12170: TNS: Connect timeout occurred

This error can be caused by several factors, such as network issues, incorrect listener configuration, or an overly restrictive firewall.

Common Causes of ORA-12170 Error

Some of the common causes of the ORA-12170 error include:

  1. Network connectivity issues between the client and the database server
  2. An incorrect or missing listener configuration
  3. Invalid SQL*Net configuration in the client's tnsnames.ora file
  4. Insufficient connection timeout value
  5. Firewall restrictions between the client and the database server

Step-by-Step Solution to Fix ORA-12170 Error

Follow these steps to resolve the ORA-12170 error:

Step 1: Verify the Basic Network Connectivity

First, ensure that the client can connect to the database server over the network. You can use the ping command to test the basic network connectivity.

ping <database_server_hostname/IP>

If the ping command fails, check your network configuration and ensure that the client and the database server can communicate with each other.

Step 2: Check the Listener Configuration

Ensure that the Oracle listener is running on the database server and is configured correctly. You can use the lsnrctl status command on the server to check the listener's status.

lsnrctl status

If the listener is not running, start it using the lsnrctl start command.

lsnrctl start

If the listener is running but is not configured correctly, edit the listener.ora file on the server and update the configuration as needed.

Step 3: Validate the SQL*Net Configuration

On the client side, check the tnsnames.ora file for the correct SQL*Net configuration. Ensure that the hostname, port, and service name in the configuration match the listener configuration on the database server.

Here's a sample tnsnames.ora configuration:

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <database_server_hostname/IP>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb)
    )
  )

Step 4: Test the Connection with TNSPING

Use the tnsping utility on the client to test the connection to the Oracle database server.

tnsping MYDB

If the tnsping test fails, review the previous steps to ensure that the network connectivity, listener configuration, and SQL*Net configuration are correct.

Step 5: Adjust the Connection Timeout

If the tnsping test is successful but you still encounter the ORA-12170 error, consider increasing the connection timeout value. You can do this by adding the TIMEOUT parameter to the CONNECT_DATA section of the tnsnames.ora file.

MYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <database_server_hostname/IP>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb)
      (TIMEOUT = 5000)
    )
  )

In the example above, the connection timeout is set to 5000 milliseconds (5 seconds).

FAQ

What is the default connection timeout value for Oracle databases?

By default, the connection timeout value for Oracle databases is set to 60 seconds.

How can I check the current connection timeout value?

You can check the current connection timeout value in the tnsnames.ora file on the client side. Look for the TIMEOUT parameter in the CONNECT_DATA section.

Can firewall restrictions cause the ORA-12170 error?

Yes, firewall restrictions between the client and the database server can cause the ORA-12170 error. Ensure that the necessary ports (usually 1521 for Oracle databases) are open on the firewall.

Can I change the connection timeout value on the server side?

Yes, you can change the connection timeout value on the server side by editing the listener.ora file and adding the INBOUND_CONNECT_TIMEOUT parameter in the SID_DESC section.

How can I troubleshoot network issues between the client and the database server?

You can use various network troubleshooting tools, such as ping, traceroute, or telnet, to identify network connectivity issues between the client and the database server.

Learn more about Oracle Listener

Oracle SQL*Net Configuration

Oracle TNSPING Utility

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.