DEV Community

umzzil nng
umzzil nng

Posted on Originally published at oraerror.com

Oracle ORA-12224 Error: Causes and Solutions Complete Guide

ORA-12224: TNS: No Listener — Causes, Fixes, and Prevention

ORA-12224 is one of the most common Oracle connectivity errors, occurring when a client attempts to establish a database connection but cannot reach the TNS listener on the server. In simple terms, the client is knocking on the database door, but there's no listener (doorman) to answer. This error can appear in any environment — development, QA, or production — and must be resolved quickly to restore service.


Top 3 Causes

1. Oracle Listener Process Is Not Running

The most frequent cause is that the listener daemon or Windows service has stopped. This happens after server reboots without auto-start configured, accidental shutdowns, or listener crashes due to resource exhaustion.

-- Check listener status (run in OS terminal, not SQL*Plus)
-- $ lsnrctl status

-- Start the listener
-- $ lsnrctl start

-- Start a named listener
-- $ lsnrctl start LISTENER_PROD

-- After starting, force the database to register its services
ALTER SYSTEM REGISTER;

-- Verify registered services
-- $ lsnrctl services
Enter fullscreen mode Exit fullscreen mode

2. Misconfigured listener.ora or tnsnames.ora

Incorrect hostnames, port numbers, SID, or service names in configuration files will prevent successful connections. This is especially common after migrations, IP changes, or port updates where config files are not updated accordingly.

-- Correct tnsnames.ora example
/*
PRODDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db-prod.example.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PRODDB.example.com)
    )
  )
*/

-- Test connectivity using tnsping
-- $ tnsping PRODDB

-- Check current listener and service parameters inside the DB
SELECT name, value
FROM   v$parameter
WHERE  name IN (
    'local_listener',
    'remote_listener',
    'service_names',
    'db_name',
    'db_domain'
)
ORDER BY name;
Enter fullscreen mode Exit fullscreen mode

3. Firewall or Network Blocking Port 1521

Even if the listener is running correctly, a firewall rule blocking TCP port 1521 will result in ORA-12224. This is increasingly common in cloud environments (AWS Security Groups, Azure NSGs, OCI Security Lists) where port rules are often overlooked during initial setup.

-- Test port accessibility from client (OS commands)
-- $ telnet db-prod.example.com 1521
-- $ nc -zv db-prod.example.com 1521

-- Verify listener is bound to the correct port on the server
-- $ netstat -tlnp | grep 1521
-- $ ss -tlnp | grep 1521

-- Allow port 1521 on Linux firewalld
-- $ firewall-cmd --permanent --add-port=1521/tcp
-- $ firewall-cmd --reload

-- Check active sessions after connectivity is restored
SELECT sid, serial#, username, status, machine, program
FROM   v$session
WHERE  type = 'USER'
ORDER  BY logon_time DESC;
Enter fullscreen mode Exit fullscreen mode

Quick Fix Summary

-- Step 1: Check and restart listener
-- $ lsnrctl status
-- $ lsnrctl stop && lsnrctl start

-- Step 2: Re-register DB services with listener
ALTER SYSTEM REGISTER;

-- Step 3: Validate tnsnames connectivity
-- $ tnsping <your_tns_alias>

-- Step 4: Review listener log for errors
-- $ tail -100 $ORACLE_BASE/diag/tnslsnr/<host>/listener/trace/listener.log

-- Step 5: Check DB network parameters
SELECT name, value
FROM   v$parameter
WHERE  name LIKE '%listener%'
   OR  name LIKE '%service%'
ORDER  BY name;
Enter fullscreen mode Exit fullscreen mode

Prevention Tips

1. Configure Listener Auto-Start and Monitoring
Register the Oracle listener as a system service (systemd on Linux, Windows Service) to ensure it starts automatically on reboot. Set up monitoring tools such as Oracle Enterprise Manager, Nagios, or Zabbix to check port 1521 and the listener process at regular intervals (every 1–5 minutes), with immediate alerting on failure.

2. Version-Control Your Network Config Files
Treat listener.ora, tnsnames.ora, and sqlnet.ora as code. Store them in a version control system (Git), always back up before changes, and validate with tnsping and lsnrctl status immediately after every modification. Never apply changes directly in production without a tested rollback plan.


Related Errors

Error Code Description
ORA-12541 TNS: No listener — similar to ORA-12224, address unreachable
ORA-12514 Listener running but requested service name not registered
ORA-12505 Listener running but specified SID not recognized
ORA-12170 TNS connect timeout — listener reachable but not responding in time

📖 Want a more detailed guide?
Check out the full in-depth version (Korean) on oraerror.com — includes detailed analysis, additional SQL examples, and prevention tips.

Top comments (0)