Oracle errors

ORA-12154: TNS: could not resolve the connect identifier

ORA-12154: TNS:could not resolve the connect identifier specified

The client could not turn the connection name you used into an address. The alias is not in the tnsnames.ora the client is reading, or the client is reading a different file than you think. Fix the alias or connect with host:port/service directly.

What it means

This error happens on the client before any network call. A connect identifier such as PROD must be resolved — usually through tnsnames.ora — into host, port and service. ORA-12154 means that lookup failed. The database and listener are not involved yet.

Common causes

How to fix it

  1. Check which file is used: the TNS_ADMIN environment variable, else the Oracle home’s network/admin folder.
  2. Look for the alias in that file and check its parentheses.
  3. Bypass the lookup with Easy Connect: host:1521/service_name.
  4. In SQLlightspeed you can connect with host, port and service directly, or point the connection to the tnsnames.ora path you want.

Example

Easy Connect needs no tnsnames.ora:

sqlplus app_user@//db-host.example.com:1521/ORCLPDB1

A minimal tnsnames.ora entry:

PROD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db-host.example.com)(PORT = 1521))
    (CONNECT_DATA = (SERVICE_NAME = ORCLPDB1)))

In SQLlightspeed

When a statement fails, SQLlightspeed’s error panel shows the error code with a plain-language explanation and a suggestion for what to do next, together with Oracle’s own message and a link to Oracle’s documentation — for this error and dozens of other common ones.

Related errors

ORA-12514ORA-01017ORA-00942 All Oracle errors →

Oracle documentation for ORA-12154. Oracle is a registered trademark of Oracle Corporation. SQLlightspeed is not affiliated with Oracle.