Skip to content

ORA-12516, ORA-12519, ORA-12520: Listener Has No Handler

ORA-12519 and ORA-12516 hit under load or right after a restart: the instance ran out of processes and the listener stopped handing out connections. How to count who's holding them, and size pools so it stops happening.

ora-12519 ora-12516 ora-12520 oracle-listener processes-limit connection-pool oracle-net oracle-database
Gopi Gorantala
Reading Progress

On This Page

Picture the session count on a dashboard. It sits at about 180 all day. Someone starts a rolling deploy of the card-authorisation service, and over eleven minutes the line climbs in steps (one step per new pod) until it flattens against 300. Right at that ceiling the new pods start logging ORA-12519, the health checks fail, the orchestrator kills the pods, and the old ones, still holding their full pools, keep the line pinned at 300 the whole time.

That flat line at the top is the whole story of ORA-12519, ORA-12516 and ORA-12520 most of the time. The listener is up, it knows your service, and it's refusing you anyway, because the instance behind it has no room for another server process. The error says "listener". The cause usually lives in your connection pools.

ORA-12519, ORA-12516 and ORA-12520 as your client sees them

The three messages, as Oracle's 19c and 21c error reference words them:

ORA-12516: TNS:listener could not find available handler with matching protocol stack
ORA-12519: TNS:no appropriate service handler found
ORA-12520: TNS:listener could not find available handler for requested type of server

From the Oracle JDBC thin driver it arrives wrapped, and this is the form most people paste into a search box:

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found

Oracle AI Database 26ai rewrote ORA-12516 into a long, specific message that names the listener's address, the protocol and the service, and appends a CONNECTION_ID you can grep for in trace files. The 26ai Net Services guide's entry for ORA-12516 shows this shape:

ORA-12516: Cannot connect to database.
Listener at host 10.9.7.5 port 1522 does not have protocol handler
  for tcp ready or registered for service sales_service.example.com.
(CONNECTION_ID=1ABcDEabCd1aB+AbCdE1aB==)

The ORA-12519 help page still lists the short message for 19c, 21c and 26ai. So on a mixed estate you'll see both styles in the same incident channel. Same problem.

When it shows up tells you more than the wording does. These errors cluster at three moments: during a load test, during a rolling deploy, and in the first minute after the database or listener comes back from a restart. If you get one at 3 p.m. on a quiet Tuesday with nothing changing, suspect a leak (below), not a storm.

Is the listener refusing, or is the instance full?

Two minutes of triage. On the database host, as the Oracle software owner:

lsnrctl services            # look at the handler line under your service

Under each service, the listener prints one handler per way it can hand you off. For a dedicated-server setup that's a "DEDICATED" handler with an established: counter, a refused: counter and a state:. The shape is this (placeholders, not output from a run):

Service "FREEPDB1" has 1 instance(s).
  Instance "FREE", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:<n> refused:<n> state:blocked
         LOCAL SERVER

state:ready means the listener will hand out connections. state:blocked means it won't, and a climbing refused: counter is every ORA-12519 your apps just ate. If you've never read this output line by line, I wrote up lsnrctl status and services separately.

Then, as a DBA user, ask the instance how close it is to its ceilings:

SELECT resource_name, current_utilization, max_utilization, limit_value
FROM   v$resource_limit
WHERE  resource_name IN ('processes', 'sessions');

If max_utilization for processes equals limit_value, you've found it: the instance hit PROCESSES at some point since startup, and the handler got blocked. If neither number is anywhere near its limit and the handler is still blocked, you're looking at a different problem: restricted mode, an instance that's still starting, or a registration that went stale. Those are ORA-12528 and friends, and the fix isn't in this article.

And if what your app actually printed was ORA-12514 or ORA-12541, stop here. Those mean the listener had never heard of the service, or nobody was listening. The comparison post sorts those out in a minute.

Starve a throwaway instance of processes

You want to see this happen on purpose before you trust any fix. The lab below runs against a disposable Oracle Database Free container. Don't run it against anything shared. I should be upfront: the session I wrote this in had no Docker daemon and no network to pull an image, so I couldn't execute it here, and there are no output blocks below that pretend otherwise. The commands are what you run; the messages you'll compare against are Oracle's documented ones from Section 1.

What you need. Docker with about 4 GB free for the container, a JDK 17 or newer, and an ojdbc11 jar from Maven Central (group com.oracle.database.jdbc, artifact ojdbc11; any 23.x release). The image is gvenzl/oracle-free:23-slim-faststart. Pin the exact tag you pulled in your notes, because these images move.

Step 1: start it.

docker run -d --name lab-oracle -p 1521:1521 \
  -e ORACLE_PASSWORD=LabOnly_1 -e APP_USER=authz -e APP_USER_PASSWORD=authz \
  gvenzl/oracle-free:23-slim-faststart
docker logs -f lab-oracle      # wait for DATABASE IS READY TO USE!

Step 2: shrink PROCESSES and restart. PROCESSES is static: ALTER SYSTEM can only write it to the SPFILE, and it takes effect at the next startup. It's set in the root container, not per PDB.

docker exec -i lab-oracle sqlplus -s / as sysdba <<'SQL'
SELECT COUNT(*) AS background_procs FROM v$process WHERE background = '1';
ALTER SYSTEM SET processes = 120 SCOPE = SPFILE;
SQL
docker restart lab-oracle

Look at that first count before you pick the number. Background processes count against PROCESSES too, and a Free instance runs a fair few of them. You want the limit low enough that a few dozen client connections tip it over, and high enough that the instance still starts. If docker logs shows the instance failing to come up, you went too low; set it higher through sqlplus / as sysdba with STARTUP after fixing the SPFILE, or throw the container away and start again. That's what it's for.

Step 3: the code that triggers it. A stand-in for an authorisation service whose pool never gives anything back:

import java.sql.*;
import java.util.*;

public class Storm {
    public static void main(String[] args) throws Exception {
        String url = "jdbc:oracle:thin:@//localhost:1521/FREEPDB1";
        List<Connection> held = new ArrayList<>();
        for (int i = 1; i <= 200; i++) {
            try {
                held.add(DriverManager.getConnection(url, "authz", "authz")); // kept open on purpose: each one pins a server process
                System.out.println("open: " + i);
            } catch (SQLException e) {
                System.out.println("failed at " + i + ": " + e.getMessage());
                break;
            }
        }
        Thread.sleep(60_000); // hold them so you can look at lsnrctl and v$resource_limit
    }
}
java -cp ojdbc11.jar Storm.java

What you should see. A run of open: lines, then failed at N with the listener-refused message from Section 1, and N will sit roughly at your PROCESSES minus the background processes. While it sleeps, run docker exec lab-oracle lsnrctl services and look for the DEDICATED handler in state:blocked, then the v$resource_limit query from the triage section.

The near-miss. Sometimes the failure is ORA-00020: maximum number of processes (120) exceeded instead. That happens when the listener still thought there was room and handed the connection off, and the instance itself said no. Same root cause, different layer refusing. The next section explains why both exist.

The forcing levers, and what production uses. PROCESSES of 120 is a toy. Production instances I've looked after run anywhere from a few hundred to a few thousand. And a single client opening connections in a tight loop replaces what is really ten app pods each warming a 30-connection pool at once.

Environment-specific triggers. You'll hit ORA-12520 rather than 12519 if the connect string asks for (SERVER=SHARED) and the instance has no shared-server dispatchers registered, or asks for (SERVER=DEDICATED) when only dispatchers are available. You'll more likely see ORA-12516 on older releases and on setups with dispatchers configured. In my experience the code you get varies with version and handler setup more than with the actual cause, which is why one article covers all three.

Teardown. docker rm -f lab-oracle. The faststart image keeps its datafiles inside the container unless you mounted a volume, so that's the whole cleanup.

The plain version

Every dedicated-server connection to Oracle gets its own server process on the database host, and the instance won't run more than PROCESSES of them, background processes included. When the instance is full, it tells the listener to stop handing out new connections for that service, and the listener answers every new connection attempt with ORA-12519 (or 12516, or 12520, depending on handler type and version) until something disconnects.

So the listener isn't broken. It's the bouncer reading a sign the instance put up.

Why the listener says no before the database does

A quick reminder of the plumbing. The listener is the process on port 1521 that accepts your TCP connection, looks at the service name you asked for, and hands you off to the database. It doesn't know about your service from config files, usually. The instance registers itself: a background process called LREG (PMON did this before 12c) pushes the list of services, their handlers, and the instance's current load to the listener. That's dynamic registration, and it's the same mechanism behind ORA-12514.

The load part matters here. Along with "I serve FREEPDB1", the instance tells the listener how busy it is. When the instance is at its process ceiling, the handler for that service gets marked blocked in the listener's view, and the listener refuses new connects up front. That's cheaper than forking a server process only to have it die on arrival. When processes free up, the next registration update flips the handler back to ready.

Here's the part that took me longest to believe. The listener's picture is an update, not a live feed. Registration happens on startup, on changes, and periodically, and between updates the listener is working from the last numbers it got. Which explains the two failure codes from one cause. If the listener's picture is current and says full, you get ORA-12519 from the listener. If the listener's picture is a few seconds stale and says "room left", it hands you off, the instance tries to give you a process, and you get ORA-00020 from the database instead. Under a connection storm you'll often see both in the same log, interleaved, and they're the same incident.

It also explains why these errors can outlast the storm by a little. Connections close, v$resource_limit shows headroom again, and for a short window the listener keeps refusing because it hasn't heard. Run ALTER SYSTEM REGISTER and the instance pushes an update right away. That doesn't create room; it only makes the listener notice room that's already there.

The wrong turn almost everyone takes first is assuming SESSIONS is the ceiling. It's the number people raise because it sounds right. But a dedicated-server connection costs one process and one session, and the default SESSIONS is derived from PROCESSES: in 19c and 23ai the SESSIONS reference gives it as (1.5 × PROCESSES) + 22. With default settings you'll run out of processes long before sessions. When you run out of sessions first (a PDB with its own lower SESSIONS, say) the error is ORA-00018, not 12519.

I went through the error reference for all three codes in 19c, 21c and 26ai, the Net Services guide, and the PROCESSES and SESSIONS reference pages before writing this, mostly so you don't have to line them up yourself the next time an upgrade changes the wording.

Counting connections before you touch PROCESSES

The top forum answer for ORA-12519 is still "increase processes". Sometimes that's right. Usually it's the database equivalent of adding lanes to a motorway: the pools grow to fill whatever you give them, and you've also given every one of those processes PGA memory and CPU to fight over. Count first.

Who's holding the processes right now:

SELECT s.machine, s.program, s.username, s.status, COUNT(*) AS conns,
       MAX(s.last_call_et) AS longest_idle_secs
FROM   v$session s
WHERE  s.type = 'USER'
GROUP  BY s.machine, s.program, s.username, s.status
ORDER  BY conns DESC;

Read it as an inventory. Each row is a client host and program. Multiply what you see by what you expected: if authz-7f9c shows 50 connections and its maximumPoolSize is 50, that pod's pool is full, which is normal for HikariCP because minimumIdle defaults to the maximum. If a host you've never heard of holds 140 INACTIVE sessions with last_call_et in the tens of thousands of seconds, somebody's batch job or BI tool is camping on your processes. That's a leak, and no amount of PROCESSES fixes a leak.

How much is background overhead:

SELECT COUNT(*) FROM v$process WHERE background = '1';

Has it hit the wall before: max_utilization in v$resource_limit is the high-water mark since startup. If it equals the limit and nobody noticed until today, you've been close for a while.

Now do the arithmetic that should have been done when the pools were configured:

pods x maxPoolSize            (every app talking to this database)
+ pods x maxPoolSize          (again, for the length of a rolling deploy)
+ batch jobs, BI tools, DBAs, monitoring agents
+ background processes
+ headroom (I use 15-20%)
= the PROCESSES you need

The second line is the one everyone forgets. During a rolling deploy, old pods hold full pools while new pods warm theirs. For a few minutes you need twice the app-side connections. That's my graph from the top of this article.

Then pick the fix that matches what you found:

What the count showed Fix What it costs
A client holding far more idle sessions than it needs Shrink that pool or set an idle timeout on it; fix the app that never closes connections A change in someone else's config, and an argument
Pools correctly sized but too many pods Lower maximumPoolSize per pod; most services need far fewer connections than they ask for More waiting for a connection in the app under peak load
Deploy surge only Deploy with maxSurge of one pod, or have new pods warm up slowly Slower deploys
The arithmetic genuinely exceeds PROCESSES Raise PROCESSES in the SPFILE and restart A restart, more PGA and memory per process, and checking SESSIONS/TRANSACTIONS defaults move with it
ORA-12520 specifically Make the connect string's SERVER= match what the instance offers, or configure dispatchers if you really want shared server Usually nothing; it's a config mismatch

If you do raise it, it's this, run in the root container by a DBA, followed by a restart:

ALTER SYSTEM SET processes = 600 SCOPE = SPFILE;

PROCESSES can't be changed in a running instance and can't be set per PDB. If you want one PDB to stop eating the whole instance, set SESSIONS inside that PDB instead (it's PDB-modifiable and can't exceed the CDB's value), and accept that its clients will see ORA-00018 when they hit it.

Two things that aren't fixes. Restarting the listener: it comes back, the instance re-registers as full, and you're blocked again in seconds. And retrying in a tight loop from every pod: that's how a restart turns into a storm. If your pool retries, give it backoff.

Pools sized against the database, not the app

The structural fix is to stop letting each service decide on its own how many connections the database will carry. I keep a single budget per database, written down, owned by whoever owns the database. Each service gets an allocation, and its maximumPoolSize times its maximum pod count (surge included) has to fit inside it. New service, new line in the budget, before anything ships.

In practice the allocations end up small. A card-authorisation service doing a few thousand requests a second with queries that take a couple of milliseconds doesn't need 50 connections per pod; it needs maybe 10, and adding more makes latency worse once the database's CPUs are busy. What I'd actually put in a Spring Boot service's config:

spring.datasource.url=jdbc:oracle:thin:@//db-prod:1521/authz_svc
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.max-lifetime=1500000
spring.datasource.hikari.connection-timeout=5000

Each service gets its own service name in Oracle, too (authz_svc above, rather than the PDB's default service). Then lsnrctl services and v$session.service_name tell you instantly which application is involved, and you can stop one service without touching the others. Pool sizing and Hikari's settings in depth belong to the Spring Boot series; how pools survive restarts and firewall cuts is in Oracle connection pools that survive restarts.

The alert that fires at 80 percent

You want to know you're near the ceiling days before the listener tells you:

  • Alert when current_utilization / limit_value for processes passes 80% for more than five minutes, and page at 90%.
  • Track max_utilization after every deploy. If it jumped by the size of one deploy's surge, your budget is wrong even if nothing failed.
  • Graph refused: from lsnrctl services if your monitoring can scrape it. Any increase is a user who got an error.
  • Watch connections per client machine from the v$session query above, so a new tool camping on 200 sessions shows up as a new line on a chart, not as an incident.

The rest of the alert set I run is in Oracle alerts that fire before ORA- errors.

In CI, a load test against a Testcontainers Oracle with PROCESSES set to your production value (scaled to your test pod count) catches pool-size changes before they ship.

On versions: the codes and their meaning have been stable from 11g through 19c and 23ai. What changes is the wording. 26ai's long-form messages name the listener, the protocol and the service, and newer JDBC drivers attach a link to Oracle's error help page. If your log parsing or alert rules match the exact old string TNS:no appropriate service handler found, re-check them when you upgrade either the database or the driver. Match on the code instead.

Things to tape to the monitor

  • ORA-12519, 12516 and 12520 almost always mean the instance hit PROCESSES and the listener stopped handing out connections. The listener is fine.
  • ORA-00020 in the same log is the same incident, caught one layer deeper because the listener's picture was a few seconds old.
  • Count before you raise. v$session grouped by machine and program tells you who's holding the processes, and it's usually one pool or one forgotten tool.
  • Size pools from a per-database budget that includes rolling-deploy surge, not from each app's guess.
  • PROCESSES is static and root-only. Raising it means a restart and more memory per process, so it's the last fix, not the first.

What people search after an ORA-12519

How do I fix ORA-12519 in SQL Developer or SQL*Plus?

You don't fix it in the client. The client is being refused because the instance is out of processes. Ask a DBA to run the v$resource_limit and v$session queries above; when sessions free up, your connection will work without any change on your side.

Should I increase PROCESSES or SESSIONS for ORA-12519?

PROCESSES, and only after counting who's using them. With default settings SESSIONS is derived as (1.5 × PROCESSES) + 22 in 19c and 23ai, so it's rarely the limit you hit first. Raising PROCESSES needs SCOPE=SPFILE and an instance restart.

Why do I get ORA-12519 right after restarting the database?

Every app's pool reconnects at the same moment, often to a full minimum size, and the instance fills up in seconds. Stagger pool warm-up, set minimumIdle sensibly, and give pool retries a backoff so a restart doesn't turn into a connection storm.

What's the difference between ORA-12519 and ORA-12514?

ORA-12514 means the listener has never heard of the service you asked for: wrong name, or not registered yet. ORA-12519 means it knows the service and is refusing because there's no available handler, usually because the instance is full. The comparison article covers the whole family of connection errors.

ora-12519ora-12516ora-12520oracle-listenerprocesses-limitconnection-pooloracle-netoracle-database

Staff engineer architecting Kafka and Flink platforms for banking, where a dropped event is a reconciliation break, not a retry. Through javahandbook.com, I share production-tested guidance on building reliable event-driven systems.

Comments