Oracle "ORA-12514: listener does not currently know of service": check the name, then the registration
Fix Oracle ORA-12514: list the services the listener knows, use the right service name, open the PDB, register the database with the listener, and fix LOCAL_LISTENER.
by OhSudo ··
Not sure this is your cause?Find it step by step: Can't connect to the database →
ORA-12514: TNS:listener does not currently know of service requested in connect descriptorRecent clients word it more helpfully:
ORA-12514: Cannot connect to database. Service SHOP is not registered with the listener at host 10.0.0.5 port 1521.The good news: the listener is running, and you reached it. It has a list of services, and the one you asked for isn’t on it. So either you’re asking for the wrong name, or the database hasn’t told the listener about itself.
- Clientasks for service SHOPconnects to
- Listenerrunning, reached(works)looks it up(fails)
- Registered servicesno SHOP(breaks here)
TL;DR
On the database server:
lsnrctl statusThe Services Summary lists every name the listener knows. Connect with one of them:
sqlplus app@//10.0.0.5:1521/ORCLPDB1If yours isn’t listed, register the database, as an admin:
1. What does the listener know?
lsnrctl statusServices Summary...Service "FREE" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service...Service "freepdb1" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service...The command completed successfullylsnrctl services gives more detail. Now compare with what you asked for, in your connection string or tnsnames.ora. Names aren’t case-sensitive, and typos and old names are common: a PDB renamed, or a connection string copied from another environment.
2. Service name, not SID
Two different things are often mixed up. Easy Connect, host:port/NAME, always means a service name. In tnsnames.ora, check which one the entry uses:
SHOP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.5)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = shop)) )SID = ORCL in place of SERVICE_NAME asks for an instance by its old-style name. Since Oracle 12c, a pluggable database (PDB) can only be reached by its service name, so a SID entry for it fails. Use SERVICE_NAME. To see the right names from inside the database:
3. The database, or the PDB, isn’t open
A database that’s down, or still starting, hasn’t registered its services. A PDB that’s closed is listed, and can’t accept connections. Check, as SYSDBA:
Open a PDB, and make it open again after restarts:
Without SAVE STATE, PDBs come up closed after each restart, and this error returns every time the server reboots.
4. Registration
The database registers itself with the listener, every minute or so. Right after the listener or the database starts, there’s a short window when the service isn’t known yet. Force it:
If registration never happens, the database is probably looking for the listener in the wrong place. That’s typical with a listener on a port other than 1521, or on another address:
SHOW PARAMETER local_listener;ALTER SYSTEM SET local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.0.5)(PORT=1522))';ALTER SYSTEM REGISTER;Then lsnrctl status should show your services within seconds.
5. Static registration
Some tasks connect while the database is down, such as starting it remotely, or RMAN duplication. Those need the service written into listener.ora, because a stopped database can’t register:
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = shop) (ORACLE_HOME = /opt/oracle/product/19c/dbhome_1) (SID_NAME = ORCL) ) )Then lsnrctl reload. Such entries show with the status UNKNOWN, which is normal for them.
6. Docker
With gvenzl/oracle-free, the default PDB is FREEPDB1, and ORACLE_DATABASE adds another. Connect from the host with the published port:
sqlplus app/password@//localhost:1521/FREEPDB1Right after the container starts, wait for DATABASE IS READY TO USE! in docker logs. Before that, you get this error, as the services aren’t registered yet.
Warning
Don’t restart the listener to fix this. It doesn’t help when the name is wrong, and it drops new connections for everyone while it restarts. Check lsnrctl status first, which changes nothing. Also keep port 1521 off the public internet, as the Port Lookup explains.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.