Skip to content
Home » Oracle Database » How to Resolve ORA-12514: TNS:listener does not currently know of service requested in connect

How to Resolve ORA-12514: TNS:listener does not currently know of service requested in connect

ORA-12514 in PL/SQL Developer

ORA-12514

ORA-12514 means that the listener cannot find any matched service with yours, so it cannot establish the connection with the database for you. As a result, it responds ORA-12514 to alert the failed connection.

As a DBA, I have seen several kinds of ORA-12514 in different scenarios and solved them by different means. Here I divide scenarios that could throw ORA-12514 into several error patterns as below:

  1. Common Situations
  2. Restarting a Database
  3. Switching over to Standby
  4. Using a Database Link
  5. Database Hanging or Crashed

Only one thing that can be sure in ORA-12514 is that the target listener is up and running. That is to say, the listener is reachable.

For unknown requested SID, the listener throws ORA-12505: TNS:listener does not currently know of SID given in connect. It may have different error patterns from this post.

ORA-12514 in Common Situations

Let’s see how we get ORA-12514. First of all, we have to make sure the listener on the database server is reachable by using tnsping.

C:\Users\ed>tnsping ora11g

TNS Ping Utility for 64-bit Windows: Version 12.1.0.1.0 - Production on 22-JUL-2014 19:24:04

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
C:\oracle\app\client\ed\product\12.1.0\client_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL)))
OK (60 msec)

OK, the remote listener is up and reachable. Please note that, the message of successful tnsping did not indicate that the service name is existing on the remote listener.

Next, we test the connection to the database by sqlplus (SQL*Plus).

C:\Users\ed>sqlplus hr/hr@ora11g
...
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Enter user-name:

Cause

When the connection came, the listener found no matched service name registered with it. Consequently, the listener had no idea which database should be used to service the connection. Here are some possible causes of ORA-12514:

1. No instance

The database was not available or say idle, no any dynamic services registered with the listener. That's why we saw ORA-12514.

2. Mismatched service name

The service name of the connect descriptor in tnsnames.ora did not match the service name in the listener. That is to say, the listener does not currently know of service requested in connect descriptor.

3. Not registered

If the database instance is up and running, the service name may not registered with the listener at specific port as you thought. By default, the service port of listener is 1521. But sometimes, it could switch to another port, say 1522.

Please note that, ORA-12514 is an error threw by the listener specifically for the client side. The database is no way to know such problem.

Solutions

The solutions to ORA-12514 are to make sure the following things:

1. The database is available

If there's no instance, then no service name will register with the listener. You should startup the instance, then LREG will automatically register the service in 60 seconds.

If you are sure that the database is up and running and still got ORA-12514, things may be complicated. Let's keep looking for other solutions.

2. The service names are matched

The service name in the connect descriptor of client's tnsnames.ora shall match the service registered in the listener. Sometimes, it's just a typo problem.

In short, the service names in the following 3 parties should be matched with each other in order to solve ORA-12514.

Service Names Shall Match for Solving ORA-12514
Service Names Shall Match for Solving ORA-12514
  • Connect descriptor.
  • The listener.
  • The database.

We talk about them respectively below.

Connect Descriptor

Let's see an example of connect identifier. In which, the body is a connect descriptor.

[oracle@test ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
...
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  )

The question is, where is tnsnames.ora?

The Listener

The connect descriptor is easily checked, but how do we check the service names of the listener? See the following command:

[oracle@test ~]$ lsnrctl status
...
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...

For a specific listener name, you should do this:

[oracle@test ~]$ lsnrctl status <listener_name>
The Database

If there's no matched service name in the listener, we should check the service names of the instance by OS authentication. No credentials are needed.

[oracle@test ~]$ sqlplus / as sysdba
...
SQL> show parameter service_names

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL

In case that you have no way to query the database, you can make a guess. Usually but not always, the service name is the same as the database unique name (DB_UNIQUE_NAME). The database unique name is the same as the instance name ($ORACLE_SID) for a single-instance database.

If both service names in the client and database are matched, but the listener showed a different service name or "The listener supports no services". The database may register a different listener, let's keep reading this post.

3. The host and port are both right

Sometime, we may go for the wrong destination of the listener, either host or port was incorrect. As a result, we saw ORA-12514 because there's no matched service name with that listener. We should check the host and port in the connect descriptor of the TNS name.

Chances are, the correct hostname may be resolved as the wrong IP address by DNS. Consequently, connections took us to the wrong database server. This could happen when we switched from an old machine to a new database server. So we should focus on name resolution problem first.

For those ORA-12514 caused by name resolution, we can use the IP address instead of hostname to connect the database for clients to work around it. Additionally, DBA should also check both values of HOST and PORT in listener.ora.

During the troubleshooting on the name resolution, you might see TNS-12545: Connect failed because target host or object does not exist temporarily.

4. Instance registers it services with the right listener

The instance may register with the another listener which services whatever port other than 1521. Consequently, no service name is supported by that listener.

That's why we always see ORA-12514 only in clients or TNS-12514 in the listener's log, the database instance will never know such problem.

Now we have a question: What listener is the instance using? If the database is using a different listener other than the default one, we can check a parameter named LOCAL_LISTENER for sure:

SQL> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (ADDRESS=(PROTOCOL=TCP)(HOST=o
                                                 racle-11g-server)(PORT=1522))

If the default listener at port 1521 in the same machine is used, the value could be empty. Otherwise, we will see the listener description like the above.

In a very rare case, the database uses a remote listener to register its service names. This is what Class of Secure Transports (COST) fights against.

For more troubleshooting beside ORA-12514, you may refer to Oracle 18c Net Services Administrator's Guide: 15 Testing Connections.

ORA-12514 When Restart a Database

It's pretty easy to explain why you got ORA-12514 when you restart a database. Please compare the following two cases.

Connect to the database through listener

[oracle@test ~]$ sqlplus /nolog
...
SQL> conn sys@orcl as sysdba
Enter password:
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

We saw ORA-12514 after we tried to startup the stopped database. Here is the reason: When you shutdown the instance, you lost the connection from the database and the service was unregistered from the listener, no more service information of the database on the listener. Therefore, ORA-12514 notified that you can't do any further to this database in this way.

To solve ORA-12514 thoroughly, you should add a static service registration to the listener for your database. Otherwise, you have to connect to the database by OS authentication.

Let's see how to avoid ORA-12514 if you are going to do critical jobs like shutdown or startup database through OS authentication.

Connect to the database through OS authentication

You don't have to provide the password through OS authentication.

[oracle@test ~]$ sqlplus /nolog
...
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1553305600 bytes
Fixed Size                  2253544 bytes
Variable Size             956304664 bytes
Database Buffers          587202560 bytes
Redo Buffers                7544832 bytes
Database mounted.
Database opened.

Can you tell the difference? By this method, you can never lose your connection during down time no matter the listener is up or not. No ORA-12514 interrupts you.

By the way, I talked about how to connecting an idle, NOMOUNT or RESTRICT database from remote clients in another post. It may help you to clarify some concepts about ORA-12514.

ORA-12514 When Switchover to Standby

DGMGRL> switchover to standby;
Performing switchover NOW, please wait...
Operation requires a connection to instance "primary" on database "standby"
Connecting to instance "primary"...
Connected.
New primary database "standby" is opening...
Operation requires startup of instance "primary" on database "primary"
Starting instance "primary"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Failed.
Warning: You are no longer connected to ORACLE.

This kind of error pattern of ORA-12514 is the most confusing, because you might have no idea what's going on according to the last message "Failed" in console. This is what's going on:

  1. The former standby is up and now playing the primary role.
  2. The former primary is down and going to play the standby role, but the data guard broker is unable to mount the instance due to the lost contact. As a result, we saw ORA-12514 in DGMGRL.

That is to say, the switchover is incomplete, but it does not mean a failure. This is because the former primary database is down and the broker lost the contact that caused ORA-12514.

Here are the actions that you have to take in order to complete the switchover. Please start up and mount the former "primary" database manually. After that, the data guard will automatically synchronize the data so as to complete the switchover.

The preventive action to ORA-12514 in an incomplete switchover is to add a very special static service in listener.ora for data guard broker to use.

A database link is just like a client which is trying to connect the remote database.

SQL> conn hr/hr
Connected.
SQL> select first_name from employees@ora11g_hr;
select first_name from employees@ora11g_hr
                                 *
ERROR at line 1:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

If the database link has been reliable for a long time, you should check the availability of the remote database. The causes that we have talked about in the section of ORA-12514 in Common Situations are still sustained. They may be:

  • The remote database is down. This is the most common cause of ORA-12514.
  • The connect descriptor in the local tnsnames.ora has been changed.
  • The service name of the remote database has been changed.
  • Another listener is used for servicing the remote database.

Usually, this type of ORA-12514 does not complain about the database link, except that you defined the database link with its own connect descriptor.

For example, we can create a database link with a full connect descriptor like this:

SQL> create database link ora11g_hr connect to hr identified by hr using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORCL)))';

Database link created.

As you can see, we did not use a connect identifier, instead, we use a full connect descriptor. Therefore, if there's anything wrong with the connect descriptor, we have to drop the database link then create a new one for solving ORA-12514.

Database Hanging or Crashed

Chances are, the database seems to be crashed or too busy to update its service status to the listener. Therefore, the listener had no choice but to respond you the error.

28 thoughts on “How to Resolve ORA-12514: TNS:listener does not currently know of service requested in connect”

    1. Thanks Barbaros. I really appreciate your detail explanation. I have finally got my pdb connection working by using the following as suggested to identify the associated service registered with the listner.

      [oracle@test ~]$ sqlplus / as sysdba
      ...
      SQL> show parameter service_names
      
      NAME                                 TYPE        VALUE
      ------------------------------------ ----------- ------------------------------
      service_names                        string      ORCL
  1. One thing I would add. On a local host, for Oracle 12.2, the service (Windows 10 Enterprise) was configured to use a specific Oracle login keyed to the sid. The service would not start because there was no password provided/stored. I changed the service to start with a logon as a local system account. This seems a little strange to me, but

  2. Hi ED Chen,
    Thank your such a useful post.
    How to resolve in case, started an instance with nomount. Actually this is needed while I am trying to create a physical standby database for RMAN DUPLICATE.

    Appreciate your help to resolve the issue as I am stuck. Please note it is in AIX7.2

  3. I am using a Multitenant inside a Virtual Box running Linux. The first step to connect was given in the official Oracle documentation was to execute the below line:

    $ export ORACLE_SID=cdb1

    Once I executed this line I havent been able to connect even once using the below command:

    $ sqlplus / as sysdba

    It asks for username and password and even thought I am giving the correct ones (was working before I executed the export ORACLE_SID command), I am getting the ORA-12514: TNS:listener does not currently know of service requested in connect descriptor error.

    So I am unable to execute below to check for service_names:

    SQL> show parameter service_names

    since I am not able to login. I haven even modified the tnsnames.ora in all ways possible, and tnsping also works.

    Am I missing something or doing anything wrong?

    1. For OS authentication, Oracle needs to know $ORACLE_SID and $ORACLE_HOME, you should ensure that both environment variables are well set. You may check /etc/oratab for sure in a single-instance environment. Additionally, please take care the letter case of both values. The value of ORACLE_SID is usually uppercase.

      To look up what services are registering with the listener, you may use lsnrctl status.

  4. Hi,
    In tnsnames.ora file we have to change SERVICE_NAME to SID inside the tnsnames.ora to fix the error .
    ORA-12514: TNS :the listener process does not currently know the service indicated in the connection descriptor (Exception Encountered)

    Could you please let me know why we have to change it and what is the target setting in prod.

    Regards,

  5. Hi ,

    I have oracle database which I have to connect to execute some queries for my testing. I am able to connect to DB using SQL developer tool but not when I am trying to connect with ODBC driver DSN settings which is Oracle 19g client. I am getting the above error with ODBC but not with SQL developer.

    I have configured tnsnames.ora as well with connection string and able to do tnsping as well.

  6. Hi,

    Wanted to also add my thanks to you for this very well written article with clear steps and great explanation. When sifting through other partial solutions it was great to find your site which is very clear and easy to read with excellent links. Although your steps didn’t solve my problem it gave me very fast understanding of what is going on (not touched oracle for about 10 years!) and where to look for problems.
    FYI my problem appears to have been caused by a server with multiple IP addresses, so when I changed the HOST to use the ‘main’ IP address instead of the server name all started working.

    Thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *