Skip to content
Home » Oracle » How to Resolve ORA-12545: Connect failed because target host or object does not exist

How to Resolve ORA-12545: Connect failed because target host or object does not exist

ORA-12545 and TNS-12545

ORA-12545 is the same as TNS-12545, they all indicate that the destination you provide in the connection string or description is not valid.

Let's see how we reproduce TNS-12545.

C:\Users\ed>tnsping compdb

TNS Ping Utility for 64-bit Windows: Version 12.1.0.1.0 - Production on 21-JUL-2014 19:10:59

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
C:\oracle\app\client\ed\product\12.1.0\client_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = primary01)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = compdb)))
TNS-12545: Connect failed because target host or object does not exist

TNS-12545 complains about hostname can not be resolve. As we can see, the network service name points to a host called primary01 which could be the source of problem.

Let's resolve the hostname by nslookup through DNS 10.10.10.10.

C:\Users\ed>nslookup primary01 10.10.10.10
Server:         10.10.10.10
Address:        10.10.10.10#53

** server can't find primary01: NXDOMAIN

Obviously, DNS has no record about primary01. Next, you should check /etc/hosts, it may be a typo there or you misspelled the hostname in tnsnames.ora.

The solution is easy. You can add the IP-Hostname mapping record to either /etc/hosts or DNS.

C:\Users\ed>notepad %SystemRoot%\System32\drivers\etc\hosts
...
10.1.2.123    primary01 primary01.example.com

Then we test the result.

C:\Users\ed>ping primary01

Pinging primary01 [10.1.2.123] with 32 bytes of data:
Reply from 10.1.2.123: bytes=32 time<1ms TTL=64
Reply from 10.1.2.123: bytes=32 time<1ms TTL=64
Reply from 10.1.2.123: bytes=32 time<1ms TTL=64
Reply from 10.1.2.123: bytes=32 time<1ms TTL=64

Ping statistics for 10.1.2.123:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

That's how we resolve TNS-12545.

Further reading: TNSPING Errors Collections

For more connection troubleshooting, you may refer to Oracle 19c Net Services Administrator's Guide: 15 Testing Connections.

2 thoughts on “How to Resolve ORA-12545: Connect failed because target host or object does not exist”

  1. Hello Team,

    I am trying to tnsping but there is same issue getting below are the error please assist.
    NS-12545: Connect failed because target host or object does not exist

Leave a Reply

Your email address will not be published. Required fields are marked *