ocx_Oracle ORA-12541 tns no listener

本小妞迷上赌 提交于 2019-12-10 19:16:18

问题


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


回答1:


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.




回答2:


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)



回答3:


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.



来源:https://stackoverflow.com/questions/15772351/ocx-oracle-ora-12541-tns-no-listener

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!