I try to connect to a remote oracle server by cx_Oracle:
db = cx_Oracle.connect('username', 'password', dsn_tns)
but it says databaseError: ORA-12541 tns no listener
First, make sure that the listener is up and running. To do this, go to the Control Panel into Services under NT or listener control program (LSNRCTL). If the listener is up and running, the problem may lie with the listener not having been associated with the correct instance or protocol.
ORA-12541: TNS:no listener. Cause: The connection request could not be completed because the listener is not running. Action: Ensure that the supplied destination address matches one of the addresses used by the listener - compare the TNSNAMES.
By default, the listener. ora file is located in the ORACLE_HOME/network/admin directory.
I was able to connect via db client (e.g datagrip), but I got the No Listener error when i connect from python script because my original connection string did not specify the port. I was following the cx_Oracle doc
This post helped me by specifying the port this way:
ip = '192.168.0.1'
port = 1521
SID = 'YOURSIDHERE'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
db = cx_Oracle.connect('username', 'password', dsn_tns)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With