Fix for ORA-12541 error: TNS:no listener when connecting applications to Oracle Database

ORA-12541 error: TNS:no listener when connecting applications to Oracle Database

Why does the ORA-12541 error occur?

This error indicates that the TNS Listener, the process responsible for managing incoming connections to the database, is not active or is unreachable. The most common causes include:
  • The listener service is stopped on the database server.
  • Incorrect configuration in the listener.ora file (port, IP address, or service name).
  • Network issues blocking the default port (1521).

Diagnosis and step-by-step solution

1. Check the Listener status

Run the following command in the Oracle server console:
lsnrctl status
If the Listener is not active, the command will display a message similar to 'TNS-12541: TNS:no listener'.

2. Start the listener service

To reactivate it, use:
lsnrctl start
If the command fails, check the user permissions or restart the service from Services (Windows) or systemctl (Linux).

3. Validate the configuration in listener.ora

Locate the file at $ORACLE_HOME/network/admin/listener.ora and confirm:
  • The port (PORT) matches the one used in the connection string.
  • The HOST address points to the correct server IP.
Example of a valid configuration:
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = servidor.oracle)(PORT = 1521))
  )

4. Test the connection from the client

Update the tnsnames.ora file on the client machine to ensure that the connection alias (TNS) matches the server parameters. Use tnsping [servicio] to test the path.

Additional diagnostic tools

Frequently Asked Questions (FAQs)

Can I use a port other than 1521?

Yes, but you must update both the listener.ora and the connection strings on the clients to reflect the change.

How do I know if the port is blocked by the firewall?

Run telnet [IP_servidor] [puerto] from the client machine. If the connection fails, check the firewall rules.

Could the error be due to the Oracle version?

It's unlikely, but verify that the drivers (ODBC/JDBC) on the client are compatible with the server version.
Comparte este contenido:

Deja un comentario

🤖 IA

×
Hola. ¿Qué duda o consulta tienes sobre este contenido?