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
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
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)
makedsn()
also accepts service_name='foo'
instead of an SID, which is what I needed. cx-oracle.readthedocs.io/en/6.4/module.html#cx_Oracle.makedsn –
Dingus This error may occur if the listener.ora file (on the Oracle server itself) is configured to listen for "localhost" instead of the machine name.
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = WN700014)(PORT = 1521)) ) )
See this post.
In my case it was due to the fact that my server port was wrong:
./install_database_new.sh localhost:1511 XE full
I changed the port to "1521" and I could connect.
© 2022 - 2024 — McMap. All rights reserved.
dsn
in this way solved my problem. – During