ORA-12541: TNS No
Listener – Complete Fix
The ORA-12541: TNS:no listener error indicates that the Oracle client is attempting to connect to a database, but there is no listener process running on the specified host and port. This is most commonly caused by the listener service being stopped or a mismatch in the network configuration. This error occurs when the Oracle listener service is not running.
Causes
- Listener
service stopped
- Wrong
port number
- Incorrect listener
configuration
Solution
Step 1: Verify and Start the Listener
The first step is to check if the listener is
active on the database server.
On Windows:
1. Open the Services window
(press Win + R, type services.msc, and hit Enter).
2. Locate the service
named OracleXETNSListener (or similar, such as OracleOraDB19Home1TNSListener).
3. If the status is
not Running, right-click it and select Start.
4. Set the Startup
Type to Automatic to prevent future occurrences.
On Linux/Unix:
1. Log in as the oracle user.
2. Run the command: lsnrctl status.
3. If the listener is
down, start it using: lsnrctl
start
Step 2: Check Network Configuration Files
If the listener is running
but you still see the error, there is likely a mismatch between your client and server settings.
1. Locate the files: Both listener.ora (server-side) and tnsnames.ora (client-side) are typically in %ORACLE_HOME%\network\admin.
2. Verify Host and Port: Ensure the HOST and PORT (usually 1521) in the tnsnames.ora file match exactly what is defined in the
server's listener.ora.
3. Use IP instead of
Hostname: If
DNS resolution is failing, try replacing the hostname with the server's
static IP address in both files.
4. Restart the Listener: After any file
changes, run lsnrctl
stop followed
by lsnrctl start.
Step 3: Test Connectivity
Use these tools to confirm the connection
path is clear:
- TNSPING: Run tnsping <service_name> from the
command prompt. A "Successful" message indicates the client can
reach the listener.
- Telnet: Test if the
port is open through firewalls by running telnet <server_ip> 1521. If the screen
goes blank, the port is open; if it says, "Connect failed," a
firewall is likely blocking it.
Step 4: Register the Database (If Necessary)
If lsnrctl status shows the listener is running but lists
"The listener supports no services," your database may not be registered.
1. Connect to the
database via SQL*Plus: sqlplus
/ as sysdba.
2. Run the command: ALTER SYSTEM REGISTER;.
3. Re-check the status
with lsnrctl status to ensure
your service (e.g., XE or ORCL) is now listed as READY.
Conclusion
Ensure listener is running and properly
configured.
No comments:
Post a Comment