I need to connect to an Oracle database from a perl script, it works in my tests and when using sqlplus, but not in production. This is a summary of the situation:

Oracle 11g XE ( : (Test environment)
   sqlplus : OK
   perl    : OK

Oracle 11g    ( : (Production environment)
   sqlplus : OK
   perl    : ERROR

The error reported is: Connect failed because target host or object does not exist

I have triple checked the connection settings and are not mistaken.


  • Test Server: Windows Server 2012
  • Production Server: Windows Server (Unknown version)
  • Client: Ubuntu 18.04 x64
  • Perl: 5.26.1
  • SQL*Plus:

SQL*Plus command:

sqlplus64 user/[email protected]/db_sid

Perl script:

use DBI;
$driver = "Oracle";
$sid    = "db_sid";
$host   = "";
$dsn    = "DBI:$driver:sid=$sid;host=$host";
$dbh    = DBI->connect($dsn, "user", "password");

Note: I won't be able to test or execute anything in the production environment until next month.

What could be the issue?

  • The host is not found, perhaps a firewall issue. Commented Dec 23, 2019 at 11:08
  • How do you connect with sqlplus? Usually you have to provide the port when you give SID and host. Typically you use the DB alias, see also metacpan.org/pod/DBD::Oracle#connect Commented Dec 23, 2019 at 11:12
  • Does the perl script requires another port open that I'm not aware? Btw, I was connected directly to the server (cross cable). I have updated the question including the sqlplus command (the server is using the default port). Thanks for the link. In 11.2, DRCP may be enabled, and it might be related to that or any other option that the server requires (and that sqlplus command is using by default).
    – lepe
    Commented Dec 24, 2019 at 1:23
  • Try DBI:Oracle: for $dsn Commented Dec 24, 2019 at 8:19
  • @WernfriedDomscheit : I will try that the next time and let you know if it worked. Thanks.
    – lepe
    Commented Dec 25, 2019 at 1:58

1 Answer 1


The connection string format is wrong. Use

$dsn = "DBI:$driver:$host/$sid";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.