When you’re sure all the TNS listener (SID_LIST_LISTENER in this case) services and db_domain are fine, but you still face the ORA-12537: TNS:connection closed error when trying to remotely access an open database, what can you do next?
[[email protected] admin]$ sqlplus sys/******@MYDB as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 3 17:45:29 2021 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-12537: TNS:connection closed
Here’s a quick tip — if you’ve been an Oracle DBA for long enough, you’ll know this workaround solves a variety of issues:
[[email protected] admin]$ cd $ORACLE_HOME/bin [[email protected] bin]$ ls -lrt oracle -rwxr-x--x. 1 oracle oinstall 242993632 Dec 18 19:20 oracle [[email protected] bin]$ chmod 6751 oracle [[email protected] bin]$ ls -lrt oracle -rwsr-s--x. 1 oracle oinstall 242993632 Dec 18 19:20 oracle
As you can see, the CHMOD 6751 did it again!
The reason this happened to me is, somehow, these permissions were wrong in my LOCAL host (the one I was trying to use the SQLPlus* from).
I hope my experience helps you. If you have any questions or anything to add, please leave me a comment.
Want to talk with an expert? Schedule a call with our team to get the conversation started.
I’m facing the following error when trying to make a connection to oracle always free database.
Failed to connect: { [Error: ORA-12537: TNS:connection closed] errorNum: 12537, offset: 0 }
Here is my script:
const oracledb = require('oracledb');
console.log('Getting connection');
let connection = oracledb.getConnection({
user: 'ADMIN',
password: '*****',
connectString: '*****'
}).then(() => {
console.log('Connection established');
}).catch((err) => {
console.log('Failed to connect: ', err);
});
Here are my version strings:
> process.platform
win32
> process.version
v10.16.3
> process.arch
x64
> require('oracledb').versionString
'4.0.1'
I’m trying to connect to Autonomous Transaction Processing Instance from Oracle Always Free cloud with database version 18c.
Thanks for taking the time to read this. Do let me know if more info is required from me.
From the Cloud GUI page for your database, click ‘DB Connection’ to download the Client Credentials wallet.
Enter a new wallet password when prompted — this will not actually be needed for use with node-oracledb.
Unzip wallet.zip and edit sqlnet.ora. Set DIRECTORY to the directory with the extracted files. Keep the files safe. For node-oracledb you only need cwallet.sso, sqlnet.ora, and tnsnames.ora
Or don’t edit sqlnet. if you put the extracted files in a default location like instantclient_19_3/network/admin. In this case there is also no need to set TNS_ADMIN
$ export TNS_ADMIN=/Users/cjones/q/Cloud/alwaysfree
$ sqlplus -l admin@cjdb1_high
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Oct 27 11:11:52 2019
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Enter password:
Last Successful login time: Sun Oct 27 2019 11:07:38 +11:00
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL ADMIN@cjdb1_high>
The next stage would be to create a normal (non admin) user to mess around with. Something like this:
define USERNAME = cj
begin execute immediate 'drop user &USERNAME cascade'; exception when others then if sqlcode <> -1918 then raise; end if; end;
/
create user &USERNAME;
alter user &USERNAME
default tablespace data
temporary tablespace temp
account unlock
quota unlimited on data;
grant connect
, resource
to &USERNAME;
grant create session
, create table
, create procedure
, create sequence
, create trigger
, create view
, create synonym
, alter session
, create type
, soda_app
to &USERNAME;
password &USERNAME
I’m working on a blog post for this.
I did as you mentioned and then I used the newly created username and password in oracledb.getConnection(). The error remains the same. Am I missing something?
FIrewalls, typos, proxies?
I’m not using any proxies and turning off all firewalls didn’t change a thing. Rechecked my username and password multiple times. I’m able to connect through SQL developer but not through oracledb in nodejs. Is it possible to turn on additional logging to know what is causing this problem, because my instance is certainly on as I’m able to connect to it through other means?
Start by giving us actual screen logs (not screen shots — please) of a terminal window showing the listing of the directory with the wallet, the contents in sqlnet.ora, you setting TNS_ADMIN (if you don’t use a default location for the wallet files), showing PATH containing the Instant Client libraries, and then running Nodejs
Sure. Here’s the directory listing of the wallet placed inside network/admin of instant client.
Volume in drive C is Windows-SSD
Volume Serial Number is 94D1-6E5D
Directory of C:oracleinstantclient-basic-windows.x64-19.3.0.0.0dbruinstantclient_19_3networkadmin
10/27/2019 08:54 AM <DIR> .
10/27/2019 08:54 AM <DIR> ..
10/27/2019 08:53 AM 6,661 cwallet.sso
10/27/2019 08:53 AM 6,616 ewallet.p12
10/27/2019 08:53 AM 3,241 keystore.jks
10/27/2019 08:53 AM 87 ojdbc.properties
10/27/2019 08:53 AM 114 sqlnet.ora
10/27/2019 08:53 AM 1,786 tnsnames.ora
10/27/2019 08:53 AM 3,335 truststore.jks
7 File(s) 21,840 bytes
2 Dir(s) 358,877,769,728 bytes free
Contents of sqlnet.ora file:
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="?/network/admin")))
SSL_SERVER_DN_MATCH=yes
My path:
echo %PATH%
-----;C:oracleinstantclient-basic-windows.x64-19.3.0.0.0dbruinstantclient_19_3;-----
Contents of temp.js
const oracledb = require('oracledb');
console.log('Getting connection');
let connection = oracledb.getConnection({
user: 'DUMMY',
password: 'Dummy1@Password',
connectString: 'adb.uk-london-1.oraclecloud.com:1522/**************_tp.atp.oraclecloud.com'
}).then((res) => {
console.log('Connection established:', res);
}).catch((err) => {
console.log('Failed to connect: ', err);
});
node temp.js
Getting connection
Failed to connect: { [Error: ORA-12537: TNS:connection closed] errorNum: 12537, offset: 0 }
Really stuck on this for a couple of days now. I’ve recently started with the oracle database and the worst part is that I remember it connecting previously. Thanks again for taking your time going through this issue. Highly appreciated.
@dmcghan Thanks a ton mate! Your video was really clear and helpful in explaining what to do and why we’re doing it. Great content!
@a1diablo Was updating sqlnet.ora really necessary as part of your solution? The string «?/network/admin» should be being expanded by the Oracle net code to (in your case) C:oracleinstantclient-basic-windows.x64-19.3.0.0.0dbruinstantclient_19_3networkadmin
@cjbj Not really. What I understood from the behavior was, that I cannot use connect strings directly in nodejs code. I had to use the name from tnsnames.ora and set TNS_ADMIN as the path of the wallet contents; only then it would work.
Since your wallet was in the default directory C:oracleinstantclient-basic-windows.x64-19.3.0.0.0dbruinstantclient_19_3networkadmin you don’t need to set TNS_ADMIN or edit sqlnet.ora
We performed an EBS R12.2 RAC to RAC clone and after successful completion of cloning we were not able to connect database using sqlplus command and it was giving the below error:
[oracle@racnode1 12.1.0]$ sqlplus apps@EBSRAC1
SQL*Plus: Release 12.1.0.2.0 Production on Tue Feb 14 08:25:38 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-12537: TNS:connection closed
Solution:
There is an issue with the permission on oracle binary and its not allowing the connections.
[oracle@racnode1 12.1.0]$ ls -lrt bin/oracle
-rwxr-x--x. 1 oracle oinstall 324002305 Dec 19 13:34 bin/oracle
Change the permissions as mentioned below and it will work:
[oracle@racnode1 12.1.0]$ chmod 6751 bin/oracle
[oracle@racnode1 12.1.0]$ ls -lrt bin/oracle
-rwsr-s--x. 1 oracle oinstall 324002305 Dec 19 13:34 bin/oracle
[oracle@racnode1 12.1.0]$
Thanks for reading.
regards,
X A H E E R
Syed Zaheer is a computer science engineering graduate and enthusiastic database professional with over a decade of experience in implementation and management of complex environments.
He has extensive experience in managing multi-vendor UNIX operating systems, storage, databases and applications. He is regular contributor to OTN forums (http://community.oracle.com) honored with the status of “Guru” by the Oracle Community.
He is a technical writer for Oracle Technology Network and has authored a book on Oracle E-Business suite R12.2 with Apress: Practical Oracle E-Business Suite: An Implementation and Management Guide
A B.tech Engineering graduate in CSIT with more than 8+ Years of IT experience in Administering Multi-vendor UNIX Servers, Oracle Applications and databases.
May 7, 2020
Hi,
Sometimes You can get “TNS-12537: TNS:connection closed” error.
Details of error are as follows.
TNS-12537: TNS:connection closed
Cause: “End of file” condition has been reached; partner has disconnected.
Action: None needed; this is an information message.
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname>)(PORT=1521))) TNS-12532: TNS:invalid argument TNS-12560: TNS:protocol adapter error TNS-502: Invalid argument 32-bit Windows Error: 515: Unknown error Error listening on: (ADDRESS=(PROTOCOL=TCP)(Host=<hostname>)(Port=1562)) TNS-12560: TNS:protocol adapter error TNS-00584: Valid node checking configuration error Connecting to (ADDRESS=(PROTOCOL=TCP)(Host=hostname)(Port=1521)) TNS-12537: TNS:connection closed TNS-12560: TNS:protocol adapter error TNS-00507: Connection closed
This error is related with the Permission or ownership or group permission, so check them if they are ok or not.
Check permission.
[[email protected] ~]$ ll $ORACLE_HOME/bin/oracle -rwsr-s--x. 1 oracle oinstall 239952653 Sep 11 20:36 /u01/app/oracle/product/12.1.2/dbhome_1/bin/oracle
Revoke the user execution permission from $ORACLE/bin/oracle as follows.
[[email protected] ~]$ chmod 6751 $ORACLE_HOME/bin/oracle [[email protected] ~]$ ll $ORACLE_HOME/bin/oracle -rwSr-s--x. 1 oracle oinstall 239952653 Sep 11 20:36 /u01/app/oracle/product/12.1.2/dbhome_1/bin/oracle
Or the second case of this error is as follows.
There is an invalid hostname in the TCP.INVITED_NODES list in the sqlnet.ora file.
Oracle no longer allows the listener to startup if an invalid hostname or ip address is specified in the invited_nodes list. The listener will not start if any of the hosts or ip addresses are note resolvable. The only solution to this issue is to ensure that all the hostnames and ip addresses in the invited nodes list are resolvable using ping or nslookup from the host where the listener is starting.
In some cases, the localhost might cause this behavior.
To solve this error, go to sqlnet.ora and check and fix the right INVITED_NODES IP as follows,
[[email protected] ~]$ cd $ORACLE_HOME/network/admin [[email protected] admin]$ vi sqlnet.ora TCP.INVITED_NODES=(localhost, <IP ADDRESS>) TCP.VALIDNODE_CHECKING = YES TCP.INVITED_NODES = (192.168.63.34,192.168.63.35,192.168.63.36)
Do you want to learn more details about RMAN, then read the following articles.
https://ittutorial.org/rman-backup-restore-and-recovery-tutorials-for-beginners-in-the-oracle-database/
2,153 views last month, 1 views today
About Mehmet Salih Deveci
![]()
I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA, Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].- -Oracle DBA, SQL Server DBA, APPS DBA, Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için [email protected] a mail atabilirsiniz.
- Remove From My Forums
-
Question
-
User-541003552 posted
Please can anyone help me with the below error. What do i need to do
ORA-12537: TNS:connection closed at System.Data.OracleClient.OracleException.Check(OciErrorHandle errorHandle, Int32 rc) at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName) at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
Answers
-
User281315223 posted
It’s been quite some time since I’ve interacted with any kind of Oracle environments, but you could possibly clean up your code a bit and hopefully prevent some unexpected behavior from your connections using «using» statements :
protected void AccountDetails() { try { // Assumes that strOraTEST is your connection string using(var objConn = new OracleConnection(strOraTEST)) { // Build your command to execute using(var objCmd = new OracleCommand("GET_ID", objConn)) { // Open your connection objConn.Open(); // Indicate this is a stored procedure objCmd.CommandType = CommandType.StoredProcedure; // Set up your parameters objCmd.Parameters.AddWithValue("NO","02001"); objCmd.Parameters.Add("ID", OracleType.VarChar2, 7).Direction = ParameterDirection.Output; // Execute your query objCmd.ExecuteNonQuery(); // Attempt to get your result Message.Text = Convert.ToString(objCmd.Parameters["ID"].Value); } } } catch (Exception ex) { // Otherwise, something went wrong Message.Text = ex.Message + "rn" + ex.StackTrace; } }-
Marked as answer by
Thursday, October 7, 2021 12:00 AM
-
Marked as answer by