user2237504
user2237504

Reputation: 81

ocx_Oracle 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

Upvotes: 8

Views: 23389

Answers (3)

emily
emily

Reputation: 198

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)

Upvotes: 6

Laura Liparulo
Laura Liparulo

Reputation: 2897

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.

Upvotes: 1

mweaver
mweaver

Reputation: 208

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.

Upvotes: 2

Related Questions