简体   繁体   中英

Node OracleDB connection not working in remote server

I'm using oracledb with Node and ExpressJS to develop my app. In localhost, I have no problems in my connections, but I need to configure the project in a server that connects to the database that it's in other server. When I do that, I get the error (Translated from spanish):

Error: Error: ORA-12154: TNS: the specified connection identifier could not be resolved.

This is my configuration code:

const oracleDbConfig = {
    user: "myUser",
    password: "myPassword",
    connectString: "192.168.6.129:1521/myDatabase",
}

Also, if I install my project in the database server and I run the same configuration using localhost, it works with no problem:

const oracleDbConfig = {
    user: "myUser",
    password: "myPassword",
    connectString: "localhost:1521/myDatabase",
}

Please, help me to understand the error.

Troubleshooting:

  1. NetworkCheck: Is your dbnode reachable? : dig,ping,host,nslookup
  2. FirewallCheck: Can you connect to the dbnode oracle listener? nc -vz dbnode 1521
  3. ServiceCheck: Is the database service myDatabase exposed in listener on dbnode? dbnode>$lsnrctl status | grep myDatabase

If you can mark these tree points a success, you should be able to connect.

Best of luck.

I solved the problem changing the connection string as the documentation says:

const oracleDbConfig = {
    user: "myUser",
    password: "myPassword",
    connectString: "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.129)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=myDatabase)))"
}

Both ways are valid, but I only have made it work with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM