Symptoms
- New connections fail with
ORA-00020: maximum number of processes (1500) exceeded. - Through the listener, clients often see
ORA-12516: TNS:listener could not find available handler with matching protocol stackorORA-12520instead, because the instance has stopped accepting new dedicated server connections. - Existing sessions keep working. The database is up, but anything that opens a new connection fails, including health checks, batch jobs and pool refills.
sqlplus / as sysdbacan fail with the same error, because a local SYSDBA session also needs a process.
1. Get a session
Try these in order.
- An existing DBA session. Check whether anyone on the team already has SQL*Plus or SQL Developer open. Use that session.
- A local bequeath login on the database server. Sometimes a process is freed between attempts, so try a few times:
export ORACLE_SID=PROD1
sqlplus / as sysdba
- A preliminary connection. It attaches to the SGA without creating a full session. You cannot run SQL with it, only
oradebugandshutdown abort, so it is mostly a last resort:
sqlplus -prelim / as sysdba
- Free processes from the OS. Kill a few client connections (not background processes) to make room for your own login. On Linux, dedicated server processes for remote clients are named
oracle<SID> (LOCAL=NO):
ps -eo pid,etime,args | grep "oracle${ORACLE_SID} (LOCAL=NO)" | grep -v grep | sort -k2 | head -20
kill -9 <pid> <pid>
Caution
Only kill processes that show
(LOCAL=NO). Killing a background process such asora_pmon_,ora_smon_,ora_lgwr_orora_dbw0_crashes the instance. When you kill a client process, its open transaction is rolled back, so prefer old idle connections from a known, restartable application server.
On Amazon RDS for Oracle there is no OS access. Use an existing master-user session and rdsadmin.rdsadmin_util.kill, or reboot the instance as a last resort.
2. Confirm scope and impact
SELECT resource_name, current_utilization, max_utilization, limit_value
FROM v$resource_limit
WHERE resource_name IN ('processes', 'sessions');
Find who holds the connections:
SELECT username, machine, program, status, COUNT(*) AS sessions,
ROUND(MAX(last_call_et) / 60) AS max_idle_min
FROM v$session
WHERE type = 'USER'
GROUP BY username, machine, program, status
ORDER BY sessions DESC
FETCH FIRST 20 ROWS ONLY;
On RAC, use gv$session and add inst_id. Each instance has its own processes limit.
| Pattern | Likely cause |
|---|---|
One app server or program holds hundreds of INACTIVE sessions | Connection leak, or a pool max set too high |
| Many app servers each have a few more sessions than usual | Scale-out event: autoscaling added nodes, and each node has its own pool |
Sessions ACTIVE and waiting on the same event | Database slowdown. Connections pile up because work does not finish |
Many sessions with the same program from a scheduler | A job storm or a retry loop |
Check what active sessions are waiting on:
SELECT event, COUNT(*) FROM v$session
WHERE type = 'USER' AND status = 'ACTIVE'
GROUP BY event ORDER BY 2 DESC FETCH FIRST 10 ROWS ONLY;
If most sessions are active and blocked, for example on enq: TX - row lock contention, fix the blocker first. Shedding connections only buys a few minutes.
3. Shed load safely
Ask the application team to cap or restart the pool that is the worst offender. This is cleaner than killing sessions. If you need to act from the database, kill the idle sessions of one source:
BEGIN
FOR s IN (SELECT sid, serial#, inst_id FROM gv$session
WHERE type = 'USER' AND status = 'INACTIVE'
AND machine = 'app-node-07' AND last_call_et > 1800) LOOP
EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# ||
',@' || s.inst_id || ''' IMMEDIATE';
END LOOP;
END;
/
Use last_call_et (seconds since the last call) to target sessions that are truly idle. Run v$resource_limit again to confirm current_utilization has dropped below limit_value.
Warning
Killing sessions that have uncommitted work triggers rollback, which can take a long time for big transactions. Check
v$transaction(used_ublk) for the sessions before you kill active ones.
4. Raise the limit if it is too low
PROCESSES is a static parameter, so a new value needs a restart. On RAC you can do a rolling restart.
SHOW PARAMETER processes
SHOW PARAMETER sessions
ALTER SYSTEM SET processes = 3000 SCOPE = SPFILE SID = '*';
Before you raise it, make sure the host can handle it:
- Each dedicated server process uses PGA and OS memory. Check
pga_aggregate_limitand the server's free memory. - Increase the Linux limits for the
oracleuser (nprocin/etc/security/limits.conf) and the kernel semaphore settings if needed. - If
sessionsis set explicitly in the spfile, raise it as well. Otherwise it is derived fromprocesses.
On RAC, restart one instance at a time with srvctl stop instance -db PROD -instance PROD1 and srvctl start instance -db PROD -instance PROD1, and confirm services have relocated before you move to the next instance.
Raising the limit is the right fix only if normal demand has grown. If a pool leaked, a higher limit just delays the next outage.
5. Verify recovery
current_utilizationforprocessesstays well underlimit_value(below 80%) for an hour.- No new ORA-00020 entries in the alert log:
SELECT originating_timestamp, message_text FROM v$diag_alert_ext
WHERE message_text LIKE '%ORA-00020%'
AND originating_timestamp > SYSTIMESTAMP - INTERVAL '2' HOUR
ORDER BY originating_timestamp DESC;
- Application health checks pass, and the pools you capped are stable at their new maximum.
Communicate
Tell users that new logins and transactions failed during the window, while users who were already connected were mostly unaffected. Name the application that was holding the connections, so its owners can review the pool settings.
Prevent it next time
- Alert at 80% of
processesusingv$resource_limit. - Size pools as a budget: (number of app nodes × pool max) plus headroom for jobs and DBAs must stay below
processes. Recheck the budget whenever autoscaling limits change. - Disconnect idle sessions automatically:
MAX_IDLE_TIME(minutes, 12.2 and later) at the instance level, or anIDLE_TIMEprofile limit for application users, which needsresource_limit = TRUE(the default in current releases). - Enable dead connection detection with
SQLNET.EXPIRE_TIMEin the serversqlnet.ora, so processes left behind by crashed clients are cleaned up. - For many short-lived connections, consider Database Resident Connection Pooling (DRCP) or a connection pool in the middle tier, instead of raising
processesagain and again.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get