ora-12154 error in oracle 11g and 12c

ORA-12154: TNS: could not resolve service name


This is very common error and I think faced by every single DBA. This is also asked in many Oracle DBA interviews. So  I am just giving trick  about this error.  

Full error you may see :-

ORA-12154: TNS: could not resolve service name.

This is always related to the TNS entries in tnsnames.ora plus also listner.ora file too.As the message indicates that there is something wrong with service name. That means either you have put a wrong entry in tnsnames.ora or in listner.ora (SID,HOST etc). 


So now you know that may be you have done typos in TNSNMAES.ORA file loacted at $ORACLE_HOME\network\admin. I suggest you to check the permison on file too. 


Solution on 11g and 12c is same as you need to check TNSNMAES.ORA on client on server side where ever you face the issue.