ORA-12528: TNS All Instances Blocked - Fix Listener Routing
ORA-12528: TNS All Instances Blocked
Section titled “ORA-12528: TNS All Instances Blocked”Error Overview
Section titled “Error Overview”Error Text: ORA-12528: TNS:listener: all appropriate instances are blocking new connections
The ORA-12528 error is returned by the Oracle listener when it has located one or more instances that match the requested service or SID, but every matching instance is currently in a state that blocks new connections. The listener knows the instance exists — it has a registration entry — but the instance itself has signalled that it is not ready to accept client connections.
This differs from ORA-12514 (service unknown to listener) and ORA-12541 (no listener running). With ORA-12528, the listener is running, the service is known, but the instance is explicitly refusing connections.
Common Causes
Section titled “Common Causes”1. Instance in Restricted Session Mode
Section titled “1. Instance in Restricted Session Mode”A DBA issued ALTER SYSTEM ENABLE RESTRICTED SESSION or started the database with STARTUP RESTRICT. Only users with the RESTRICTED SESSION system privilege can connect. The listener blocks all other connection attempts with ORA-12528.
2. Database in MOUNT State During Startup
Section titled “2. Database in MOUNT State During Startup”The instance is starting up and has reached MOUNT state but not yet OPEN. LREG has registered the service with the listener, but the database is not open for normal connections.
3. Instance Not Yet Registered After Startup
Section titled “3. Instance Not Yet Registered After Startup”After ALTER DATABASE OPEN, LREG sends updated service registration to the listener. There is a brief window (up to 60 seconds) before the listener updates its records. During this window, stale registration data may still indicate the instance is blocked.
4. RAC Instance Starting or Undergoing Instance Recovery
Section titled “4. RAC Instance Starting or Undergoing Instance Recovery”In a RAC environment, when one node is in the process of starting up and performing instance recovery for a previously crashed node, it may temporarily block connections at the listener level for that service.
5. PDB (Pluggable Database) in MOUNT State
Section titled “5. PDB (Pluggable Database) in MOUNT State”In Oracle Multitenant, if a specific PDB service is requested but that PDB is not open (still in MOUNT state), the listener blocks connections to that service with ORA-12528.
6. Instance Quiesced
Section titled “6. Instance Quiesced”ALTER SYSTEM QUIESCE RESTRICTED places the instance in QUIESCED state, where only active sessions may continue; new connections from non-DBA users are blocked.
Diagnostic Queries
Section titled “Diagnostic Queries”Check Instance Open Mode and Restricted Status
Section titled “Check Instance Open Mode and Restricted Status”-- Requires SYSDBA connectionSELECT instance_name, status, database_status, active_state, logins, shutdown_pendingFROM v$instance;
-- Database open modeSELECT name, open_mode, restricted, database_roleFROM v$database;Check Restricted Session Status
Section titled “Check Restricted Session Status”-- Check if restricted mode is activeSELECT valueFROM v$parameterWHERE name = 'restricted';
-- Alternative — check instance directlySELECT logins FROM v$instance;-- ALLOWED = normal, RESTRICTED = restricted session mode activeCheck Who Has RESTRICTED SESSION Privilege
Section titled “Check Who Has RESTRICTED SESSION Privilege”-- Find users who can connect during restricted modeSELECT grantee, privilege, admin_optionFROM dba_sys_privsWHERE privilege = 'RESTRICTED SESSION'ORDER BY grantee;Check PDB Status (Multitenant)
Section titled “Check PDB Status (Multitenant)”-- Check all PDB open modes from CDB$ROOTSELECT con_id, name, open_mode, restricted, recovery_statusFROM v$pdbsORDER BY con_id;
-- Services registered per PDBSELECT s.name, s.pdb, s.network_name, s.blockedFROM v$active_services sORDER BY s.pdb, s.name;Check LREG Service Registration
Section titled “Check LREG Service Registration”-- Services currently registered and their blocked statusSELECT name, blocked, pdb, goal, dtpFROM v$active_servicesORDER BY blocked DESC, name;
-- Instance registration info sent to listenerSELECT instance_name, service_name, statusFROM v$services;Listener Registration Details
Section titled “Listener Registration Details”# View what the listener currently knows about instanceslsnrctl services
# Check for BLOCKED status in listener services output:# Handler(s):# "DEDICATED" established:0 refused:0 state:blockedCheck for Active Quiesce
Section titled “Check for Active Quiesce”-- Check quiesce stateSELECT active_state FROM v$instance;-- NORMAL = no quiesce-- QUIESCING = in progress-- QUIESCED = fully quiesced, new connections blockedStep-by-Step Resolution
Section titled “Step-by-Step Resolution”1. Diagnose the Blocked State
Section titled “1. Diagnose the Blocked State”-- Connect as SYSDBA (SYSDBA connections bypass restricted/blocked states)sqlplus / as sysdba
-- Or remotely:sqlplus sys@//hostname:1521/sid as sysdba
-- Determine the exact causeSELECT instance_name, status, logins, active_state, database_statusFROM v$instance;
SELECT name, open_mode, restricted FROM v$database;2. Disable Restricted Session Mode
Section titled “2. Disable Restricted Session Mode”If the database is in restricted mode and it should be open to all users:
-- Disable restricted session modeALTER SYSTEM DISABLE RESTRICTED SESSION;
-- VerifySELECT logins FROM v$instance;-- Should return ALLOWED3. Open the Database
Section titled “3. Open the Database”If the instance is in MOUNT state and needs to be opened:
-- Open the databaseALTER DATABASE OPEN;
-- For a PDB in MOUNT state:ALTER PLUGGABLE DATABASE pdb_name OPEN;
-- Open all PDBsALTER PLUGGABLE DATABASE ALL OPEN;4. Force LREG Re-Registration
Section titled “4. Force LREG Re-Registration”After resolving the blocking condition, force an immediate listener registration update:
-- Force LREG to re-register all services with the listenerALTER SYSTEM REGISTER;# Verify the listener now shows the instance as available (not blocked)lsnrctl services# Look for: state:ready (not state:blocked)5. Exit Quiesced State
Section titled “5. Exit Quiesced State”If the database was quiesced:
-- Un-quiesce the databaseALTER SYSTEM UNQUIESCE;
-- VerifySELECT active_state FROM v$instance;-- Should return NORMAL6. Resolve Stuck RAC Instance Registration
Section titled “6. Resolve Stuck RAC Instance Registration”In a RAC environment, if one node is blocking and the listener is routing all connections to it:
# Check which instances are registered with the SCAN listenersrvctl status database -db mydb
# Check individual instance statussrvctl status instance -db mydb -instance mydb1
# If an instance is down or in restricted mode, restart itsrvctl stop instance -db mydb -instance mydb1srvctl start instance -db mydb -instance mydb17. Verify After Resolution
Section titled “7. Verify After Resolution”# Full listener service checklsnrctl services
# Expected output should show state:ready, not state:blocked# Handler(s):# "DEDICATED" established:N refused:N state:ready-- Confirm normal connections are now possible (as a non-SYSDBA user)CONNECT app_user/password@service_nameSELECT 'Connection successful' FROM DUAL;Prevention Strategies
Section titled “Prevention Strategies”1. Use STARTUP RESTRICT Intentionally and Briefly
Section titled “1. Use STARTUP RESTRICT Intentionally and Briefly”-- Controlled pattern: start restricted, do maintenance, then open to allSTARTUP RESTRICT;
-- Perform DBA-only maintenance tasks here...-- e.g., dictionary recompilation, patch application
-- Then open to all users when readyALTER SYSTEM DISABLE RESTRICTED SESSION;ALTER SYSTEM REGISTER; -- Force immediate listener update2. Automate PDB Open After CDB Startup
Section titled “2. Automate PDB Open After CDB Startup”-- Prevent PDBs from being left in MOUNT state after CDB restartALTER PLUGGABLE DATABASE ALL OPEN;ALTER PLUGGABLE DATABASE ALL SAVE STATE;
-- Verify saved stateSELECT con_name, state FROM dba_pdb_saved_states;3. Create a Database Startup Trigger to Open PDBs
Section titled “3. Create a Database Startup Trigger to Open PDBs”-- Automatically open all PDBs when the CDB startsCREATE OR REPLACE TRIGGER open_all_pdbs AFTER STARTUP ON DATABASEBEGIN EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';EXCEPTION WHEN OTHERS THEN -- Log but do not fail the trigger NULL;END;/4. Monitor Blocked Services
Section titled “4. Monitor Blocked Services”-- Schedule a periodic check for blocked servicesBEGIN DBMS_SCHEDULER.CREATE_JOB( job_name => 'MONITOR_BLOCKED_SERVICES', job_type => 'PLSQL_BLOCK', job_action => q'[ DECLARE v_blocked NUMBER; BEGIN SELECT COUNT(*) INTO v_blocked FROM v$active_services WHERE blocked = 'YES'; IF v_blocked > 0 THEN INSERT INTO dba_alerts(alert_time, alert_msg) VALUES (SYSDATE, v_blocked || ' service(s) blocked — ORA-12528 risk'); COMMIT; END IF; END; ]', repeat_interval => 'FREQ=MINUTELY;INTERVAL=5', enabled => TRUE );END;/5. Best Practices for Restricted Mode
Section titled “5. Best Practices for Restricted Mode”- Always set a reminder or scheduled job to disable restricted mode after maintenance
- Grant
RESTRICTED SESSIONonly to DBA accounts, not application users - Document every use of
STARTUP RESTRICTin the change management log - In RAC, coordinate restricted mode across all instances to avoid split-brain routing by the listener
Related Errors
Section titled “Related Errors”- ORA-12514 - TNS Listener Does Not Currently Know of Service
- ORA-12516 - TNS Listener No Available Handler
- ORA-12518 - TNS Listener Could Not Hand Off Client Connection
- ORA-12520 - TNS No Available Handler for Shared Server
- ORA-01033 - Oracle Initialization or Shutdown in Progress
- ORA-01034 - Oracle Not Available
Emergency Response
Section titled “Emergency Response”Quick Fixes
Section titled “Quick Fixes”-
Check and clear restricted mode
SELECT logins FROM v$instance;ALTER SYSTEM DISABLE RESTRICTED SESSION; -
Open a mounted database or PDB
SELECT open_mode FROM v$database;ALTER DATABASE OPEN;-- orALTER PLUGGABLE DATABASE ALL OPEN; -
Force listener re-registration
ALTER SYSTEM REGISTER;-- Wait 30 seconds, then:-- lsnrctl services (verify state:ready)
Post-Resolution Cleanup
Section titled “Post-Resolution Cleanup”-- Confirm normal operationSELECT instance_name, status, logins, active_state FROM v$instance;SELECT name, open_mode, restricted FROM v$database;SELECT name, blocked FROM v$active_services ORDER BY blocked DESC;
-- Save PDB states to prevent recurrenceALTER PLUGGABLE DATABASE ALL SAVE STATE;
-- Confirm listener shows ready status-- lsnrctl services | grep state
-- Document the incident: why was restricted mode active?-- Update runbook to include DISABLE RESTRICTED SESSION in post-maintenance checklist