Explain Codes LogoExplain Codes Logo

Ora-12560: TNS:protocol adapter error

sql
ora-12560
tns-protocol-error
oracle-services
Alex KataevbyAlex Kataev·Jan 7, 2025
TLDR

To resolve the ORA-12560 error quickly, confirm the correct functioning of Oracle service (services.msc on Windows, ps -ef | grep pmon on Unix/Linux), and ensure it's running. Modify your ORACLE_HOME and ORACLE_SID through:

export ORACLE_HOME=/your/oracle_home; export ORACLE_SID=your_sid

Also, check and adjust your TNSNAMES.ORA and LISTENER.ORA in the network/admin folder. If changes are made, restart the listener:

lsnrctl start

Make sure that your network details in the configurations are accurate and the client and server are connected satisfactorily by host and port.

When Oracle Services Go Rogue

Start Me Up: Ensure Oracle Services

Confirm that the related Oracle database service for your instance is running. In the Windows operating system, items tagged as OracleService<SID> should be activated. Access the service via Command Prompt or Services.msc:

net start OracleService<SID>
<!-- Hey! SID got its own OracleService. Movin' up in the world, hah! -->

Or use the services interface:

  1. Press Win + R, type services.msc, and press Enter.
  2. Find OracleService<SID> in the list.
  3. Right-click and select Start if it isn't running.

Set the Stage: Environment Variables

ORACLE_SID variable should be an exact match to your active database SID. Utilize the command line to set this:

For Windows:

set ORACLE_SID=your_sid
<!-- You can't spell "Sideris" without SID. Well, you technically can, but where's the fun in that? -->

In Unix/Linux:

export ORACLE_SID=your_sid

Also, verify that the TNS_ADMIN environment variable points toward the directory where your tnsnames.ora file is. For instance:

export TNS_ADMIN=/path/to/your/network/admin

Check Your Oracle Files

Be sure to verify entries in tnsnames.ora and listener.ora for deviations. Incorrect names of services, ports, or host IP addresses will lead to the ORA-12560 error. The common localtion of tnsnames.ora is:

C:\oracle\product\10.2.0\client_1\network\admin\tnsnames.ora

Oracle Network Diagnostics

Pinging with Tnsping

Begin with the simplest of solutions: run a tnsping to your tnsalias to ensure network communication is functional:

tnsping your_tnsalias

This will validate if your client can communicate with the listener over at the Oracle server.

Reboot to Reconnect

If there are any adjustments made to your tnsnames.ora or similar network files, be sure to restart the listener:

lsnrctl reload

In some scenarios, the database, despite running, might fail to respond. You may need to restart the database:

On Windows:

sqlplus / as sysdba shutdown immediate startup
<!-- "Try restarting" — Tech support, since time immemorial -->

On Unix/Linux, this might depend on your startup scripts but typically involves connecting to SQL*Plus and executing similar commands.

The Mystery Oracle Service

If the Oracle service is missing, ORADIM utility can bail you out to create it:

oradim -new -sid your_sid -startmode auto
<!-- Who needs a magic wand when you have ORADIM? -->

The Journey to Error Resolution

Verifying Database Accessibility

The crucial part is not only to check whether the Oracle service is active but also to validate that it restarts successfully after a reboot. Ensure that the autostart feature for the database service is enabled.

Post-Recovery Database Accessibility

After a system reboot or recovery from a failure, connect to the Oracle instance with SQL*Plus to check accessibility:

sqlplus /nolog conn your_username/your_password@host:port/service
<!-- Username: admin, Password: admin. Works every time, right? -->

Deeper Dive Into Oracle and TNS

Get a grip on the Oracle network architecture. A deeper understanding of how the TNS listener interacts with the database service is crucial to avoid future mistakes. Refer to the Oracle Network Configuration Administrator's Guide for more information.

Advanced Troubleshooting Techniques

Sometimes, obscure issues such as incorrect file permissions, a corrupt Oracle software installation, or improper network infrastructure setup can trigger the ORA-12560 error. Keep an eye out for:

  1. Permissions to Oracle installation and network files.
  2. Any network equipment failure that might disrupt the Oracle service (firewalls, routers etc).
  3. Check Oracle's alert.log for any database-specific issues.