DEV Community

umzzil nng
umzzil nng

Posted on Originally published at oraerror.com

Oracle ORA-12541 Error: Causes and Solutions Complete Guide

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

What Is ORA-12541?

ORA-12541 is one of the most common Oracle connectivity errors, occurring when a client application attempts to establish a database connection but cannot reach the TNS Listener on the target server. The Oracle Listener is a critical server-side process that accepts incoming client connection requests and hands them off to the appropriate database process. Without a running listener, no new sessions can be established, making this a high-priority issue in any production environment.


Top 3 Causes

1. Oracle Listener Service Is Not Running

The most frequent cause is simply that the listener process has stopped — due to a server reboot, manual shutdown, or an unexpected crash. This immediately blocks all new incoming connections.

Check listener status and restart:

-- Check listener status (run as oracle OS user)
-- lsnrctl status

-- Start the listener
-- lsnrctl start

-- If the DB service is not auto-registered, force registration
-- Connect via: sqlplus / as sysdba
ALTER SYSTEM REGISTER;

-- Verify active services registered with the listener
SELECT name, network_name, creation_date
FROM   v$active_services
ORDER BY name;
Enter fullscreen mode Exit fullscreen mode

2. Incorrect TNS Configuration Files

A misconfigured tnsnames.ora (wrong hostname, port, or service name) or a malformed listener.ora on the server side will cause ORA-12541 even when the listener is running. Always validate both files after any infrastructure change.

Correct tnsnames.ora example:

-- tnsnames.ora (client side)
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.example.com)
    )
  )
Enter fullscreen mode Exit fullscreen mode

Correct listener.ora example:

-- listener.ora (server side)
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl.example.com)
      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
      (SID_NAME = ORCL)
    )
  )
Enter fullscreen mode Exit fullscreen mode

Test connectivity after changes:

-- Test TNS resolution (OS command)
-- tnsping ORCL

-- Verify listener-related parameters from inside the DB
SELECT name, value
FROM   v$parameter
WHERE  name IN ('local_listener', 'remote_listener', 'service_names')
ORDER BY name;
Enter fullscreen mode Exit fullscreen mode

3. Firewall Blocking Port 1521

Oracle Listener defaults to TCP port 1521. If a firewall rule — at the OS, network, or cloud security group level — blocks this port, the client receives ORA-12541 as though no listener exists at all. This often happens after OS updates or security policy changes.

-- Verify port is open and listening (Linux OS commands)
-- netstat -tlnp | grep 1521
-- ss -tlnp | grep 1521

-- Open port with firewalld (Linux)
-- firewall-cmd --permanent --add-port=1521/tcp
-- firewall-cmd --reload

-- Confirm current session connection info from inside Oracle
SELECT sys_context('USERENV', 'IP_ADDRESS')   AS client_ip,
       sys_context('USERENV', 'SERVER_HOST')  AS server_host,
       sys_context('USERENV', 'SERVICE_NAME') AS service_name
FROM   dual;
Enter fullscreen mode Exit fullscreen mode

Quick Fix Checklist

  1. Confirm listener is runninglsnrctl status
  2. Start the listener if stoppedlsnrctl start
  3. Force DB service registrationALTER SYSTEM REGISTER;
  4. Validate tnsnames.ora → check HOST, PORT, SERVICE_NAME
  5. Test network pathtnsping <alias> and telnet <host> 1521
  6. Check firewall rules → ensure port 1521 is allowed end-to-end

Prevention Tips

Automate listener startup on reboot.
Register the listener as a system service (e.g., systemd on Linux) so it starts automatically after any planned or unplanned server restart. Combine this with a monitoring alert on port 1521 availability using tools like OEM, Zabbix, or Nagios to catch outages within seconds.

Version-control your TNS configuration files.
Store tnsnames.ora, listener.ora, and sqlnet.ora in a Git repository and enforce a change management process before any modifications reach production. Always back up these files before editing, and validate changes with tnsping before closing your change window.


Related Oracle Errors

Error Code Description
ORA-12514 Listener running, but requested service name is not registered
ORA-12505 Listener running, but SID is not registered
ORA-12154 TNS alias could not be resolved in tnsnames.ora
ORA-12170 Connection attempt timed out

📖 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)