Skip to content

ORA-12541 TNS No Listener - Network Configuration Fix

Error Text: ORA-12541: TNS:no listener

This error occurs when Oracle clients cannot connect to the database because no listener process is running on the specified host and port, or the listener is not accessible due to network issues. This is a fundamental connectivity error that prevents database access.

Client Application
TNS Connect Request (Host:Port)
Network Layer
Target Server:1521 (default)
Oracle Listener Process ← ERROR: Not Found/Running
  • Listener not started - Service is down
  • Wrong port number - Client connecting to incorrect port
  • Network connectivity - Firewall or routing issues
  • Hostname resolution - DNS or hosts file problems
  • Service configuration - Listener misconfigured
Terminal window
# Check if listener is running
lsnrctl status
# Check specific listener
lsnrctl status LISTENER
lsnrctl status LISTENER_ORCL
# Show all running listeners
ps -ef | grep tnslsnr | grep -v grep
# Check listener configuration
cat $TNS_ADMIN/listener.ora
cat $ORACLE_HOME/network/admin/listener.ora
Terminal window
# Test basic network connectivity
ping <hostname>
telnet <hostname> 1521
# Alternative network tools
nc -zv <hostname> 1521
nmap -p 1521 <hostname>
# Check if port is open locally
netstat -an | grep 1521
lsof -i :1521
# DNS resolution test
nslookup <hostname>
dig <hostname>
Terminal window
# Test TNS connectivity
tnsping <service_name>
tnsping <hostname>:1521/<service_name>
# Test with different connection strings
sqlplus user/pass@hostname:1521/service_name
sqlplus user/pass@hostname:1521:SID
# Check TNS configuration
cat $TNS_ADMIN/tnsnames.ora
echo $TNS_ADMIN
echo $ORACLE_HOME
Terminal window
# Start default listener
lsnrctl start
# Start specific listener
lsnrctl start LISTENER
lsnrctl start LISTENER_ORCL
# Check listener status after start
lsnrctl status
# View listener log
tail -f $ORACLE_BASE/diag/tnslsnr/$(hostname)/listener/trace/listener.log
Terminal window
# If listener fails to start, check configuration
lsnrctl start
# Look for error messages
# Common issues and fixes:
# 1. Port already in use
netstat -an | grep 1521
# Kill process using port if needed
# 2. Permission issues
ls -la $ORACLE_HOME/bin/tnslsnr
# Should be owned by oracle user
# 3. Configuration syntax errors
lsnrctl checkconf
Terminal window
# Edit listener configuration
vi $ORACLE_HOME/network/admin/listener.ora
# Basic listener.ora template
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
# For specific hostname
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver.domain.com)(PORT = 1521))
)
)
# Multiple addresses
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver)(PORT = 1521))
)
)
# Static service registration (optional)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.domain.com)
(ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)
(SID_NAME = orcl)
)
)
Terminal window
# Stop and start listener
lsnrctl stop
lsnrctl start
# Or reload configuration
lsnrctl reload
# Verify configuration
lsnrctl status
lsnrctl services
Terminal window
# Check hostname resolution
hostname
hostname -f
cat /etc/hosts
# Add entry to /etc/hosts if needed
echo "192.168.1.100 myserver.domain.com myserver" >> /etc/hosts
# Test resolution
ping myserver
ping myserver.domain.com
Terminal window
# Check firewall status (Linux)
systemctl status firewalld
iptables -L -n | grep 1521
# Open port 1521
firewall-cmd --permanent --add-port=1521/tcp
firewall-cmd --reload
# Or disable firewall temporarily for testing
systemctl stop firewalld
# Check SELinux (if applicable)
getenforce
sestatus
Terminal window
# Wrong - using wrong port
sqlplus user/pass@server:1522/orcl
# Correct - using standard port
sqlplus user/pass@server:1521/orcl
# Alternative connection methods
sqlplus user/pass@orcl
sqlplus user/pass@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)))"
Terminal window
# Edit client tnsnames.ora
vi $TNS_ADMIN/tnsnames.ora
# Correct entry format
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = server.domain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.domain.com)
)
)
# Test after changes
tnsping ORCL
sqlplus user/pass@ORCL
Terminal window
# Create multiple listeners on different ports
# listener.ora
LISTENER1521 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = server)(PORT = 1521))
)
)
LISTENER1522 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = server)(PORT = 1522))
)
)
# Start specific listeners
lsnrctl start LISTENER1521
lsnrctl start LISTENER1522
# Check all listeners
lsnrctl status LISTENER1521
lsnrctl status LISTENER1522
-- Force database registration with listener
ALTER SYSTEM REGISTER;
-- Check local_listener parameter
SHOW PARAMETER local_listener;
-- Set local_listener if needed
ALTER SYSTEM SET local_listener = 'LISTENER_ORCL' SCOPE=BOTH;
ALTER SYSTEM SET local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=1521))' SCOPE=BOTH;
-- Register with listener
ALTER SYSTEM REGISTER;
Terminal window
# Enable listener tracing
echo "TRACE_LEVEL_LISTENER = 16" >> $ORACLE_HOME/network/admin/listener.ora
lsnrctl reload
# Enable client tracing
echo "TRACE_LEVEL_CLIENT = 16" >> $ORACLE_HOME/network/admin/sqlnet.ora
# View trace files
ls -la $ORACLE_BASE/diag/tnslsnr/*/listener/trace/
tail -f listener.log
listener_monitor.sh
#!/bin/bash
LOG_FILE="/var/log/oracle/listener_monitor.log"
# Check if listener is running
if ! lsnrctl status LISTENER > /dev/null 2>&1; then
echo "$(date): CRITICAL - Listener is down!" >> $LOG_FILE
# Attempt automatic restart
echo "$(date): Attempting to start listener..." >> $LOG_FILE
lsnrctl start LISTENER
if lsnrctl status LISTENER > /dev/null 2>&1; then
echo "$(date): SUCCESS - Listener restarted" >> $LOG_FILE
# Send notification
echo "Listener was down but has been automatically restarted" | mail -s "Listener Alert - Resolved" $EMAIL
else
echo "$(date): FAILED - Could not restart listener" >> $LOG_FILE
# Send critical alert
echo "CRITICAL: Listener is down and automatic restart failed" | mail -s "CRITICAL: Listener Down" $EMAIL
fi
else
echo "$(date): Listener is running normally" >> $LOG_FILE
fi
# Check listener registration
SERVICE_COUNT=$(lsnrctl services LISTENER 2>/dev/null | grep -c "Service ")
if [ $SERVICE_COUNT -eq 0 ]; then
echo "$(date): WARNING - No services registered with listener" >> $LOG_FILE
fi
/etc/systemd/system/oracle-listener.service
# Create systemd service for listener
[Unit]
Description=Oracle Net Listener
After=network.target
[Service]
Type=forking
User=oracle
Group=oinstall
Environment=ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
Environment=ORACLE_SID=orcl
ExecStart=/u01/app/oracle/product/19.0.0/dbhome_1/bin/lsnrctl start LISTENER
ExecStop=/u01/app/oracle/product/19.0.0/dbhome_1/bin/lsnrctl stop LISTENER
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
# Enable and start service
systemctl enable oracle-listener
systemctl start oracle-listener
-- Database health check procedure
CREATE OR REPLACE PROCEDURE check_listener_connectivity AS
v_connection_test NUMBER;
v_error_msg VARCHAR2(500);
BEGIN
-- Test connection from database perspective
BEGIN
-- This will fail if listener connectivity is broken
SELECT 1 INTO v_connection_test FROM dual;
DBMS_OUTPUT.PUT_LINE('Database connectivity: OK');
-- Check registered services
FOR svc IN (SELECT name FROM v$services WHERE name NOT LIKE 'SYS%') LOOP
DBMS_OUTPUT.PUT_LINE('Registered service: ' || svc.name);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
v_error_msg := SQLERRM;
DBMS_OUTPUT.PUT_LINE('Database connectivity issue: ' || v_error_msg);
-- Log to alert table
INSERT INTO dba_connectivity_alerts (
alert_time, alert_type, error_message
) VALUES (
SYSTIMESTAMP, 'LISTENER_CONNECTIVITY', v_error_msg
);
COMMIT;
END;
END;
/
-- Schedule connectivity check
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name => 'CHECK_LISTENER_CONNECTIVITY',
job_type => 'STORED_PROCEDURE',
job_action => 'check_listener_connectivity',
repeat_interval => 'FREQ=MINUTELY; INTERVAL=5',
enabled => TRUE
);
END;
/
Terminal window
# Check user limits
ulimit -a
# Verify oracle user can bind to port
# (Some systems require root for ports < 1024)
netstat -an | grep :1521
# Check if another process is using the port
lsof -i :1521
# SELinux issues
setsebool -P oracle_port_enabled 1
Terminal window
REM Check listener service
sc query OracleOraDB19Home1TNSListener
REM Start listener service
net start OracleOraDB19Home1TNSListener
REM Check Windows firewall
netsh advfirewall firewall show rule name="Oracle Listener"
REM Add firewall rule if needed
netsh advfirewall firewall add rule name="Oracle Listener" dir=in action=allow protocol=TCP localport=1521
  • ORA-12514 - TNS:listener does not know of service
  • ORA-12519 - TNS:no appropriate service handler
  • ORA-12154 - TNS:could not resolve connect identifier
  • ORA-03113 - End-of-file on communication channel
  1. ✓ Check if listener process is running
  2. ✓ Test network connectivity to host:port
  3. ✓ Verify listener configuration
  4. ✓ Start listener if not running
  5. ✓ Test connection after restart
  6. ✓ Check firewall and security settings
  7. ✓ Verify DNS/hostname resolution
  8. ✓ Update client connection strings if needed
Terminal window
# Check listener status
lsnrctl status
# Start listener
lsnrctl start
# Test connectivity
tnsping service_name
telnet hostname 1521
# Check configuration
cat $ORACLE_HOME/network/admin/listener.ora
# View listener log
tail -f $ORACLE_BASE/diag/tnslsnr/*/listener/trace/listener.log
  • 1521 - Default Oracle listener port
  • 1522 - Alternative Oracle port
  • 1526 - Oracle Names Server
  • 2481 - Oracle Enterprise Manager
  • 5500 - Oracle Enterprise Manager Express (12c+)