In this tutorial, let’s have a look at the reason for Error “ORA-12162: TNS:net service name is incorrectly specified” in Oracle and how to fix it.
Oracle Error Message
This is how the Oracle error message ORA-12162 looks like in general.
ORA-12162: TNS:net service name is incorrectly specified
Reason for the Error
This error message (ORA-12162) is sometimes misleading. The message states that there is an issue with the tnsnames.ora file settings where the service name is specified incorrectly. But the message “ORA-12162 TNS:net service name is incorrectly specified” appears because you have set an incorrect ORACLE_SID value.
The connect descriptor corresponding to the net service name in TNSNAMES.ORA or in the directory server (Oracle Internet Directory) is incorrectly specified.
Solution
If using local naming make sure there are no syntax errors in the corresponding connect descriptor in the TNSNAMES.ORA file. If using directory naming check the information provided through the administration used for directory naming.
For example,
Ensure that you set your $ORACLE_HOME environment variable if you are running Oracle on Windows. If you are using Linux, try setting both ORACLE_HOME and $ORACLE_SID.