Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 834
user2237504 Avatar asked Apr 02 '13 19:04

user2237504


People also ask

How do I fix 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.

What does TNS no listener mean?

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.

Can't find listener Ora file?

By default, the listener. ora file is located in the ORACLE_HOME/network/admin directory.


1 Answers

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)
like image 76
emily Avatar answered Oct 12 '22 09:10

emily