ORA-12542: TNS: Address Already in Use — Causes, Fixes & Prevention
ORA-12542 is a TNS-level Oracle error that occurs when the Oracle Listener attempts to bind to a specific IP address and port that is already occupied by another process. This is fundamentally an OS network socket conflict, not a database engine issue, and it most commonly surfaces when restarting the Oracle Listener without properly verifying that the previous listener process has fully terminated. Understanding this distinction is critical for fast diagnosis and resolution.
Top 3 Causes
1. Zombie Listener Process Still Holding the Port
The most frequent cause: after running lsnrctl stop, the underlying OS process lingers in a zombie or TIME_WAIT state, keeping port 1521 bound. Any attempt to start a new listener immediately afterward triggers ORA-12542.
-- Check existing Oracle listener sessions from inside the DB
SELECT sid, serial#, username, status, machine, program
FROM v$session
WHERE program LIKE '%TNS%'
ORDER BY logon_time DESC;
-- After confirming on OS level (Linux: lsof -i :1521 or ss -tlnp | grep 1521)
-- Kill the stale process, then restart the listener:
-- kill -9 <PID>
-- lsnrctl start LISTENER
-- Verify listener registration after restart
ALTER SYSTEM REGISTER;
SELECT name, network_name
FROM v$active_services
ORDER BY name;
2. Port Conflict with Another Application or Second Listener
In environments with multiple Oracle Homes or third-party security agents, another process may already occupy port 1521. If two listener configurations point to the same port, the second start attempt always fails with ORA-12542.
-- Check current listener parameter settings inside the DB
SHOW PARAMETER local_listener;
SHOW PARAMETER remote_listener;
-- If a port change is needed, update listener.ora (example: switch to 1522)
-- Then update local_listener accordingly:
ALTER SYSTEM SET local_listener =
'(ADDRESS=(PROTOCOL=TCP)(HOST=mydbserver)(PORT=1522))'
SCOPE = BOTH;
-- Force dynamic registration to the new listener address
ALTER SYSTEM REGISTER;
-- Confirm services are registered
SELECT name, db_unique_name
FROM v$services
ORDER BY name;
3. Misconfigured or Stale listener.ora
After server IP changes, hostname updates, or Oracle upgrades, an outdated listener.ora may reference incorrect HOST or PORT values. This can cause the listener to attempt binding to an invalid or already-used address.
-- Verify what the DB thinks its listener address is
SELECT name, value
FROM v$parameter
WHERE name IN ('local_listener', 'remote_listener', 'service_names');
-- Check listener network details
SELECT *
FROM v$listener_network;
-- Correct listener.ora example:
/*
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = correct-hostname)(PORT = 1521))
)
)
*/
-- After fixing listener.ora, restart and validate:
-- lsnrctl stop LISTENER
-- lsnrctl start LISTENER
-- lsnrctl status LISTENER
Quick Fix Summary
| Scenario | Action |
|---|---|
| Zombie listener process |
lsof -i :1521 → kill -9 <PID> → lsnrctl start
|
| Port used by another app | Change PORT in listener.ora, update tnsnames.ora
|
| Wrong HOST/IP in config | Edit listener.ora with correct HOST, restart listener |
Prevention Tips
1. Always Verify Port Clearance Before Restarting the Listener
Never assume lsnrctl stop fully releases the port immediately. Build a standard checklist that includes running ss -tlnp | grep 1521 (Linux) or netstat -ano | findstr 1521 (Windows) before executing lsnrctl start. Automating this check in a wrapper shell script eliminates human error.
2. Monitor Listener Availability Proactively
Use Oracle Enterprise Manager or a lightweight custom script to poll port 1521 at regular intervals. Set up alerts so DBAs are notified before users report connectivity failures. Also define a clear OS service startup sequence to ensure the listener always starts after all network interfaces are fully initialized — preventing race conditions that lead to ORA-12542 during server reboots.
Related Errors
- ORA-12541 — TNS: no listener (listener not running at all)
- ORA-12560 — TNS: protocol adapter error (service not started, common on Windows)
- ORA-12514 — TNS: listener does not know of service (listener running but service not registered)
- ORA-12537 — TNS: connection closed (unstable listener dropping connections)
📖 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)