ORA-12520: TNS No Available Handler - Fix Shared Server
ORA-12520: TNS Listener Could Not Find Available Handler
Section titled “ORA-12520: TNS Listener Could Not Find Available Handler”Error Overview
Section titled “Error Overview”Error Text: ORA-12520: TNS:listener could not find available handler for requested type of server
The ORA-12520 error is returned by the Oracle listener when a client requests a shared server connection (also called MTS — Multi-Threaded Server) and no dispatcher process is currently available or registered to handle that connection type. The listener cannot forward the client to a dispatcher, so it rejects the connection entirely.
This is distinct from ORA-12516 (no available handler for a dedicated connection) and ORA-12518 (handler handoff failure). ORA-12520 is specifically a shared server / dispatcher availability problem.
Common Causes
Section titled “Common Causes”1. Shared Server Not Configured or Disabled
Section titled “1. Shared Server Not Configured or Disabled”The database is running with SHARED_SERVERS=0 or DISPATCHERS parameter is not set. The listener received a request for a shared server connection but no dispatchers exist.
2. All Dispatchers at Maximum Load
Section titled “2. All Dispatchers at Maximum Load”DISPATCHERS is set but all running dispatcher processes have reached their connection limit (CONNECTIONS attribute). The listener has no dispatcher with available capacity.
3. Dispatcher Processes Crashed
Section titled “3. Dispatcher Processes Crashed”One or more dispatcher processes died abnormally. PMON should restart them, but there is a window during which no dispatcher is available to accept connections.
4. Client Requesting Shared Server via SERVER=SHARED in TNS Descriptor
Section titled “4. Client Requesting Shared Server via SERVER=SHARED in TNS Descriptor”The client tnsnames.ora or connection string explicitly specifies (SERVER=SHARED), forcing a shared server connection even though the database may be configured for dedicated connections by default.
5. SERVICE_NAMES Mismatch
Section titled “5. SERVICE_NAMES Mismatch”The service requested by the client is not registered with the listener for the shared server pathway. Dynamic service registration by LREG may not have propagated the shared server handler information yet.
6. SHARED_SERVERS Parameter Set Too Low
Section titled “6. SHARED_SERVERS Parameter Set Too Low”The SHARED_SERVERS initialization parameter defines the minimum number of shared server processes Oracle maintains. If this is set too low and peak load exceeds capacity, ORA-12520 occurs.
Diagnostic Queries
Section titled “Diagnostic Queries”Check Current Dispatcher Configuration
Section titled “Check Current Dispatcher Configuration”-- View dispatcher parametersSHOW PARAMETER dispatchers;SHOW PARAMETER shared_servers;SHOW PARAMETER max_shared_servers;
-- Active dispatchersSELECT name, status, messages, bytes, breaks, protocol, owned, createdFROM v$dispatcherORDER BY name;Check Dispatcher Load and Connections
Section titled “Check Dispatcher Load and Connections”-- Current load on each dispatcherSELECT d.name, d.status, d.messages, c.circuit_count, d.owned AS connectionsFROM v$dispatcher dLEFT JOIN ( SELECT dispatcher, COUNT(*) AS circuit_count FROM v$circuit GROUP BY dispatcher) c ON d.paddr = c.dispatcherORDER BY d.name;
-- Maximum connections per dispatcher (from DISPATCHERS parameter)-- Default is 1024 per dispatcher processSELECT name, valueFROM v$parameterWHERE name = 'dispatchers';Check Shared Server Processes
Section titled “Check Shared Server Processes”-- Active shared server processesSELECT name, status, messages, bytes, requestsFROM v$shared_serverORDER BY name;
-- Shared server request queue — high values indicate bottleneckSELECT name, queued, wait, totalqFROM v$queueWHERE type = 'COMMON';Verify Service Registration with Listener
Section titled “Verify Service Registration with Listener”-- Services registered via LREGSELECT service_id, name, network_name, pdbFROM v$active_servicesORDER BY name;
-- Check handler type for servicesSELECT s.name, h.handler_type, h.dispatcherFROM v$service s, v$dispatcher_config d, v$dispatcher hWHERE h.name IS NOT NULL;Check Client Connection Mode
Section titled “Check Client Connection Mode”-- See current sessions and their server modeSELECT sid, username, server, status, program, machineFROM v$sessionWHERE username IS NOT NULLORDER BY server, username;
-- Count by server typeSELECT server, COUNT(*) AS session_countFROM v$sessionWHERE username IS NOT NULLGROUP BY server;Listener Log Analysis
Section titled “Listener Log Analysis”# Check listener log for ORA-12520 entries# $ORACLE_BASE/diag/tnslsnr/<hostname>/listener/alert/log.xml# Or the legacy listener.log:grep -i "12520\|TNS-12520" $ORACLE_BASE/diag/tnslsnr/$(hostname)/listener/trace/listener.log | tail -50Step-by-Step Resolution
Section titled “Step-by-Step Resolution”1. Verify the Database Has Shared Server Enabled
Section titled “1. Verify the Database Has Shared Server Enabled”-- Connect as SYSDBASHOW PARAMETER shared_servers;-- If value = 0, shared server is disabled
SHOW PARAMETER dispatchers;-- If empty or null, no dispatchers are configured2. Enable or Increase Shared Server Dispatchers
Section titled “2. Enable or Increase Shared Server Dispatchers”If shared server should be active but is not configured:
-- Enable shared server with dispatchers for TCP protocolALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(SERVICE=mydbXDB)' SCOPE=BOTH;
-- Set minimum shared server processesALTER SYSTEM SET SHARED_SERVERS = 5 SCOPE=BOTH;
-- Set maximum shared server processesALTER SYSTEM SET MAX_SHARED_SERVERS = 20 SCOPE=BOTH;If dispatchers are already configured but under-provisioned:
-- Add more dispatchers by updating the DISPATCHERS parameter-- To have 3 dispatchers:ALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(DISPATCHERS=3)' SCOPE=BOTH;3. Switch Client to Dedicated Mode (Bypass the Problem)
Section titled “3. Switch Client to Dedicated Mode (Bypass the Problem)”If dedicated server connections are acceptable and shared server is not a requirement, modify the client connection descriptor to force dedicated:
# tnsnames.oraMYDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dbhost)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = mydb) (SERVER = DEDICATED) -- Force dedicated, bypasses ORA-12520 ) )Or in the connect string:
-- JDBC thin URL: add /dedicatedjdbc:oracle:thin:@//host:1521/service?oracle.net.server.type=dedicated4. Kill and Restart Stuck Dispatcher Processes
Section titled “4. Kill and Restart Stuck Dispatcher Processes”-- Identify the dispatcher process addressesSELECT name, paddr, status FROM v$dispatcher;
-- Find OS PID from paddrSELECT p.spid, d.name, d.statusFROM v$process pJOIN v$dispatcher d ON p.addr = d.paddr;# At OS level, if a dispatcher is hung:kill -9 <spid># PMON will restart the dispatcher automatically within seconds5. Force LREG to Re-Register Services
Section titled “5. Force LREG to Re-Register Services”-- Force immediate service re-registration with the listenerALTER SYSTEM REGISTER;
-- Then verify with lsnrctl:-- lsnrctl services <listener_name>-- Confirm (HANDLER=D000) entries appear for the service6. Adjust Dispatcher Connection Limit
Section titled “6. Adjust Dispatcher Connection Limit”The default connections-per-dispatcher is high (typically 1024), but it can be explicitly capped in the DISPATCHERS parameter:
-- Set dispatcher with explicit connection ceilingALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(SERVICE=mydb)(CONNECTIONS=500)(DISPATCHERS=4)' SCOPE=BOTH;Prevention Strategies
Section titled “Prevention Strategies”1. Monitor Dispatcher Saturation
Section titled “1. Monitor Dispatcher Saturation”-- Proactive dispatcher load monitoringCREATE OR REPLACE PROCEDURE monitor_dispatchers AS v_max_load NUMBER := 0.8; -- 80% threshold v_load NUMBER;BEGIN SELECT MAX(owned / NULLIF(1024, 0)) INTO v_load FROM v$dispatcher;
IF v_load > v_max_load THEN INSERT INTO dba_alerts(alert_time, alert_msg) VALUES (SYSDATE, 'Dispatcher load at ' || ROUND(v_load*100,1) || '% — ORA-12520 risk'); COMMIT; END IF;END;/2. Set Up Automatic Dispatcher Scaling
Section titled “2. Set Up Automatic Dispatcher Scaling”-- Oracle automatically scales shared servers between SHARED_SERVERS and MAX_SHARED_SERVERS-- Set a generous ceiling to allow scalingALTER SYSTEM SET SHARED_SERVERS = 5 SCOPE=BOTH;ALTER SYSTEM SET MAX_SHARED_SERVERS = 50 SCOPE=BOTH;
-- Allow Oracle to auto-tune dispatchersALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(DISPATCHERS=2)(SERVICE=mydb)' SCOPE=BOTH;3. Prefer Dedicated Connections for OLTP
Section titled “3. Prefer Dedicated Connections for OLTP”Shared server is primarily useful for reducing OS process overhead in high-connection-count environments. For modern OLTP systems using connection pools, dedicated server connections combined with proper pool sizing are preferred:
- Use
(SERVER=DEDICATED)in all TNS descriptors for connection-pooled applications - Reserve shared server for legacy client/server applications with many idle connections
- Use Oracle Connection Manager (CMAN) as an alternative for connection multiplexing
4. Regular Listener and Dispatcher Health Checks
Section titled “4. Regular Listener and Dispatcher Health Checks”-- Weekly health check querySELECT 'Dispatchers' AS component, COUNT(*) AS active_count FROM v$dispatcherUNION ALLSELECT 'Shared Svrs', COUNT(*) FROM v$shared_serverUNION ALLSELECT 'Circuits', COUNT(*) FROM v$circuit;Related Errors
Section titled “Related Errors”- ORA-12514 - TNS Listener Does Not Currently Know of Service Requested
- ORA-12516 - TNS Listener No Available Handler for Dedicated
- ORA-12518 - TNS Listener Could Not Hand Off Client Connection
- ORA-12519 - TNS No Appropriate Service Handler Found
- ORA-12528 - TNS All Instances Blocked
Emergency Response
Section titled “Emergency Response”Quick Fixes
Section titled “Quick Fixes”-
Force dedicated mode from client (fastest fix)
# Add SERVER=DEDICATED to tnsnames.ora connect descriptor(SERVER = DEDICATED) -
Increase dispatchers immediately
ALTER SYSTEM SET DISPATCHERS = '(PROTOCOL=TCP)(DISPATCHERS=5)' SCOPE=BOTH;ALTER SYSTEM REGISTER; -
Check for crashed dispatchers and force PMON restart
SELECT name, status FROM v$dispatcher;-- If any show DEAD status, identify OS PID and kill -9 at OS level
Post-Resolution Cleanup
Section titled “Post-Resolution Cleanup”-- Verify dispatchers are healthySELECT name, status, owned AS connections FROM v$dispatcher;
-- Confirm service registration-- lsnrctl services | grep -A5 DISPATCHER
-- Review if shared server is actually neededSELECT server, COUNT(*) FROM v$sessionWHERE username IS NOT NULL GROUP BY server;-- If SHARED count is low vs DEDICATED, consider switching fully to dedicated mode