> ## Content Index
> Fetch the complete content index at: https://www.ggorantala.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# ORA-12514 vs ORA-12541 vs ORA-12154: Which Connection Error?
- URL: https://www.ggorantala.dev/ora-12514-vs-ora-12541-vs-ora-12154/
- Published: 2026-12-02T18:33:26.000Z
- Updated: 2026-12-02T18:33:26.000Z
- Description: ORA-12154, ORA-12541 and ORA-12514 each tell you how far your connection got: not off your machine, no answer on the port, or a listener that doesn't know your service. How to tell them apart in a minute and fix the right layer.
- Author: Gopi Gorantala
- Tags: ora-12514, ora-12541, ora-12154, connection-errors, tnsnames, oracle-listener, oracle-net, oracle-database

These three codes are a progress bar. That's the whole trick to ORA-12514 vs ORA-12541 vs ORA-12154, and once you read them that way you stop restarting databases that were never involved.

ORA-12154 means your connection never left your machine: the client couldn't turn the name you gave it into an address. ORA-12541 means it left, reached the host, and nothing was listening on that port. ORA-12514 means it got all the way to a listener, which read your request and said it has never heard of that service. Three different layers. Three different people you might need to talk to. One family of codes that all start with `ORA-125` or `ORA-121` and all look, at 2 a.m., like "Oracle is down."

## Three codes, three distances

Here's the path a connection takes, and where each error fires:

```log
  your app                       network                  database host
 ----------                    -----------              ---------------------------
 [ name -> address ] ---X ORA-12154
          |
          v
 [ TCP to host:port ] -------------X ORA-12541 (refused: nothing on that port)
          |
          v
                                              [ listener: "which service?" ] ---X ORA-12514
                                                        |
                                                        v
                                              [ server process, login ] ---> ORA-01017, ORA-01109 ...

```

A listener, if you haven't met one, is the small process on the database host that accepts new network connections and hands each one to the right database. A service name is the logical name a database registers with that listener (`FREEPDB1`, `loyalty_app`). A TNS alias is a nickname in your client's `tnsnames.ora` file that expands into host, port and service on your machine; the database never sees it.

Everything after the listener says yes is a different class of problem: passwords, closed PDBs, privileges. If you're getting ORA-01017 or ORA-01109, you're already past all three of these.

## ORA-12514 vs ORA-12541 vs ORA-12154 at a glance

|                                | ORA-12154                                                              | ORA-12541                                                        | ORA-12514                                                                       |
| ------------------------------ | ---------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Who raises it                  | Client naming layer (SQL\*Plus, Instant Client, JDBC, python-oracledb) | Client Oracle Net, after the OS says "refused"                   | The listener, sent back to the client                                           |
| How far it got                 | Never left your machine                                                | Reached the host, nothing on that port                           | Reached a listener                                                              |
| How fast                       | Instant                                                                | Milliseconds                                                     | Milliseconds                                                                    |
| 19c-era message                | TNS:could not resolve the connect identifier specified                 | TNS:no listener                                                  | TNS:listener does not currently know of service requested in connect descriptor |
| 23ai/26ai message names        | The alias and the file it searched                                     | The host and port it tried                                       | The service and the listener's host and port                                    |
| First check                    | Which tnsnames.ora did this client read?                               | nc -vz host port from where the app runs                         | lsnrctl services on the database host                                           |
| Typical fix                    | Fix TNS\_ADMIN or use EZConnect                                        | Start the listener, fix host or port, publish the container port | Use the right service name, or fix registration                                 |
| Restarting the database helps? | Never                                                                  | Only if the listener was down with it                            | Sometimes, by accident, and that's how people learn the wrong lesson            |

## What each one looks like on your screen

### ORA-12154: the name went nowhere

The old wording tells you nothing beyond "I couldn't find it":

```log
ORA-12154: TNS:could not resolve the connect identifier specified

```

Newer clients finally name the alias and where they looked. From [Oracle's ORA-12154 page](https://docs.oracle.com/en/error-help/db/ora-12154/?ref=ggorantala.dev):

```log
ORA-12154: Cannot connect to database. Cannot find alias alias_value in repository_loc.

```

python-oracledb in thin mode does the lookup itself and has its own codes. `DPY-4027: no configuration directory specified` means it didn't find a `tnsnames.ora` at all, per the [python-oracledb troubleshooting guide](https://python-oracledb.readthedocs.io/en/stable/user%5Fguide/troubleshooting.html?ref=ggorantala.dev). If you see any of these, stop looking at the database. The full story of which file each client reads is in [ORA-12154: could not resolve the connect identifier](https://ggorantala.dev/ora-12154-could-not-resolve-connect-identifier/?ref=ggorantala.dev).

### ORA-12541: nobody home on that port

Famously terse on 19c-era clients:

```log
ORA-12541: TNS:no listener

```

The 23ai/26ai template is `ORA-12541: Cannot connect. No listener at host_port.`, and the [Net Services troubleshooting page](https://docs.oracle.com/en/database/oracle/oracle-database/26/netag/tns-12541-or-ora-12541-tns-no-listener.html?ref=ggorantala.dev) adds a detail that matters for this comparison: the address shown is the last IP the client tried, or the redirect address if a listener redirected you. So ORA-12541 can happen *after* a listener answered. More on that below.

On the Java side, older Oracle JDBC drivers tend to wrap a refused socket as `IO Error: The Network Adapter could not establish the connection` (ORA-17002, with a `ConnectException` underneath) rather than printing 12541\. Newer ones print the 23ai-style 12541 directly; there's a real Hibernate 6.6 example of `No listener at host localhost port 1521` in [the ORA-12541 write-up](https://ggorantala.dev/ora-12541-tns-no-listener/?ref=ggorantala.dev). The Network Adapter wrapper gets [its own article](https://ggorantala.dev/ora-17002-network-adapter-could-not-establish-connection/?ref=ggorantala.dev).

### ORA-12514: the listener answered and said no

```log
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

```

Older JDBC drivers prefix it with `Listener refused the connection with the following error:`, which sounds like a network refusal and isn't one. The listener was there. It refused the *service*. The 23ai/26ai form, from [Oracle's ORA-12514 page](https://docs.oracle.com/en/error-help/db/ora-12514/?ref=ggorantala.dev), carries everything you need:

```log
ORA-12514: Cannot connect to database. Service service_name is not registered with the listener at host_port. (CONNECTION_ID=connection_id)

```

python-oracledb thin raises `DPY-6001: cannot connect to database`, followed by the service-not-registered text and, helpfully, `(Similar to ORA-12514)`. I saw that exact shape in [a thread on Oracle's forums](https://forums.oracle.com/ords/apexds/post/python-oracledb-connectivity-issues-from-python-jupyter-not-7044?ref=ggorantala.dev) from someone whose `tnsnames.ora` listed a standby SCAN address that was usually down. Its refused-socket cousin is `DPY-6005: cannot connect to database`, usually with the OS error text after it.

The deep version, with the registration mechanics, is [ORA-12514: listener does not know of service](https://ggorantala.dev/ora-12514-listener-does-not-know-service/?ref=ggorantala.dev). Its close relative ORA-12505 is the same refusal for a SID instead of a service, nearly always a colon where a slash should be in a JDBC URL ([covered here](https://ggorantala.dev/ora-12505-listener-does-not-know-sid/?ref=ggorantala.dev)).

## One script, all three failures

I couldn't run an Oracle container in this session's workspace (no Docker daemon, and its network refuses the image registries), so there's no database output below. What I could do is reproduce the part of the path that decides between these three codes, because none of it needs Oracle: name resolution, DNS, and a TCP connect. That's honest about what it is. It's a probe, not a database.

Here's a stdlib-only Python script that walks a connect string through the same stages a client does and tells you where it stops. Save it as `oraprobe.py`; it runs on any machine with Python 3.

```python
#!/usr/bin/env python3
"""How far does an Oracle connect string get? Stdlib only, no Oracle client."""
import os, re, socket, sys, time

def lookup_alias(alias):
    admin = os.environ.get("TNS_ADMIN")
    if not admin:
        return None, "TNS_ADMIN is not set"
    path = os.path.join(admin, "tnsnames.ora")
    try:
        text = open(path).read()
    except OSError as e:
        return None, f"cannot read {path}: {e.strerror}"
    m = re.search(rf"^{re.escape(alias)}\s*=(.*?)(?=^\S|\Z)", text, re.M | re.S | re.I)
    if not m:
        return None, f"alias {alias} not in {path}"
    host = re.search(r"HOST\s*=\s*([^)\s]+)", m.group(1), re.I).group(1)
    port = int(re.search(r"PORT\s*=\s*(\d+)", m.group(1), re.I).group(1))
    return (host, port), path

def probe(cs, timeout=3.0):
    print(f"== {cs}")
    m = re.match(r"^(?://)?([^:/]+):(\d+)[/:](.+)$", cs)
    if m:
        host, port = m.group(1), int(m.group(2))
    else:
        hp, where = lookup_alias(cs)
        if hp is None:
            print(f"  stage 1 naming : FAIL ({where})  -> ORA-12154 territory, nothing left this machine")
            return
        host, port = hp
        print(f"  stage 1 naming : ok, {cs} -> {host}:{port} from {where}")
    try:
        addr = socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)[0][4]
        print(f"  stage 2 DNS    : ok, {host} -> {addr[0]}")
    except socket.gaierror as e:
        print(f"  stage 2 DNS    : FAIL ({e})  -> ORA-12545 / ORA-12262, not a listener problem")
        return
    t0 = time.monotonic()
    try:
        socket.create_connection((host, port), timeout=timeout).close()
        ms = (time.monotonic() - t0) * 1000
        print(f"  stage 3 TCP    : open in {ms:.1f} ms  -> something accepted; any error now is the listener's (ORA-12514/12505) or later")
    except ConnectionRefusedError:
        ms = (time.monotonic() - t0) * 1000
        print(f"  stage 3 TCP    : REFUSED in {ms:.1f} ms  -> ORA-12541, nothing listening at {host}:{port}")
    except (socket.timeout, TimeoutError):
        print(f"  stage 3 TCP    : no answer after {timeout:.0f} s  -> ORA-12170 territory, a drop not a refusal")
    except OSError as e:
        print(f"  stage 3 TCP    : FAIL ({e.strerror})")

for cs in sys.argv[1:]:
    probe(cs)

```

For the lab I gave it a one-entry `tnsnames.ora` for a loyalty-points service, and started a throwaway HTTP server on port 15210 to stand in for "something is listening":

```ini
LOYALTY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA = (SERVICE_NAME = loyalty_app)))

```

```bash
mkdir -p tns   # put the tnsnames.ora above in ./tns
python3 -m http.server 15210 --bind 127.0.0.1 >/dev/null 2>&1 &
env -u TNS_ADMIN python3 oraprobe.py LOYALTY
TNS_ADMIN=./tns python3 oraprobe.py LOYALTY POINTS \
  //no-such-host.invalid:1521/loyalty_app \
  //127.0.0.1:15210/loyalty_app \
  //10.255.255.1:1521/loyalty_app
kill %1

```

What it printed, on Python 3.13.18, Linux, December 2026:

```log
== LOYALTY
  stage 1 naming : FAIL (TNS_ADMIN is not set)  -> ORA-12154 territory, nothing left this machine
== LOYALTY
  stage 1 naming : ok, LOYALTY -> 127.0.0.1:1521 from ./tns/tnsnames.ora
  stage 2 DNS    : ok, 127.0.0.1 -> 127.0.0.1
  stage 3 TCP    : REFUSED in 0.2 ms  -> ORA-12541, nothing listening at 127.0.0.1:1521
== POINTS
  stage 1 naming : FAIL (alias POINTS not in ./tns/tnsnames.ora)  -> ORA-12154 territory, nothing left this machine
== //no-such-host.invalid:1521/loyalty_app
  stage 2 DNS    : FAIL ([Errno -2] Name or service not known)  -> ORA-12545 / ORA-12262, not a listener problem
== //127.0.0.1:15210/loyalty_app
  stage 2 DNS    : ok, 127.0.0.1 -> 127.0.0.1
  stage 3 TCP    : open in 0.1 ms  -> something accepted; any error now is the listener's (ORA-12514/12505) or later
== //10.255.255.1:1521/loyalty_app
  stage 2 DNS    : ok, 10.255.255.1 -> 10.255.255.1
  stage 3 TCP    : REFUSED in 0.2 ms  -> ORA-12541, nothing listening at 10.255.255.1:1521

```

Same alias, `LOYALTY`, failing at two different stages depending on one environment variable. That's the first lesson. The last line is the second, and I'll come back to it.

The open port on 15210 is a web server, not a listener. The probe can't tell the difference and neither can `nc`. "Port open" proves something accepted TCP; it doesn't prove that something speaks Oracle Net. If your connect string points at the wrong service on an open port, you get a different, uglier error than any of these three.

To see the real codes, run the same three mistakes against a disposable Oracle Free container on your laptop, never a shared database. I haven't run this here, so these are the expected results from the docs and the linked articles:

```bash
docker run -d --name cmp -p 1521:1521 -e ORACLE_PASSWORD=LabOnly_2026 gvenzl/oracle-free:23-slim-faststart
# wait for "DATABASE IS READY TO USE!" in docker logs cmp
docker exec -i cmp sqlplus -L system/LabOnly_2026@NOSUCHALIAS </dev/null           # expect ORA-12154
docker exec -i cmp sqlplus -L system/LabOnly_2026@//localhost:1599/FREEPDB1 </dev/null  # expect ORA-12541
docker exec -i cmp sqlplus -L system/LabOnly_2026@//localhost:1521/LOYALTY </dev/null   # expect ORA-12514
docker rm -f cmp

```

`-L` makes SQL\*Plus give up after one failed attempt instead of prompting. The container's slim image keeps its data inside the container, so `docker rm -f` is the whole teardown.

## The misreads that cost an afternoon

**"tnsping works, so it can't be the listener."** This is the most expensive one. `tnsping` resolves the alias and checks that a listener answers at that address. It never asks for your service. So `tnsping LOYALTY` can report OK while every login through `LOYALTY` dies with ORA-12514, and the team goes off to blame the app's pool config because "the network checks out." It does check out. The classic version: the database is called `loyalty` and the alias asks for `SERVICE_NAME = loyalty`, but `DB_DOMAIN` is set, so the default service it registers is `loyalty.corp.example.com` (the [SERVICE\_NAMES reference](https://docs.oracle.com/en/database/oracle/oracle-database/26/refrn/SERVICE%5FNAMES.html?ref=ggorantala.dev) gives the default as `DB_UNIQUE_NAME.DB_DOMAIN`). tnsping can't see that layer at all.

**"Listener refused the connection" means a network problem.** On older JDBC drivers that sentence prefixes ORA-12514 and ORA-12505\. People read "refused" and go and open firewall tickets. The listener answered; that's how it could refuse.

**ORA-12541 means the listener on my database host is down.** Usually. But per Oracle's own troubleshooting note, the address in the newer message can be a *redirect* address. With a RAC SCAN listener, the first hop answers and redirects you to a node's address; if that address isn't reachable from where your app runs, ORA-12541 names it, not the one in your connect string. Read the host and port in the message before you SSH anywhere.

**ORA-12541 means nothing's there, ORA-12170 means a firewall.** This was my surprise from the lab. That `10.255.255.1` address isn't a database. It isn't anything. On most networks a connect to it hangs until your timeout and you'd get ORA-12170\. In my sandbox it came back refused in 0.2 ms, because that network rejects connections it won't route instead of dropping them. A firewall configured to reject does exactly the same thing, so a perfectly healthy listener behind a rejecting firewall produces ORA-12541\. If `lsnrctl status` on the host looks fine and you still get 12541, test from the app's host, not from the database host. [ORA-12170](https://ggorantala.dev/ora-12170-tns-connect-timeout/?ref=ggorantala.dev) covers the drop case.

**ORA-12154 is a DNS problem.** It isn't. A hostname that won't resolve inside a `tnsnames.ora` entry gets [ORA-12545](https://docs.oracle.com/en/error-help/db/ora-12545/?ref=ggorantala.dev) ("target host or object does not exist"). Newer clients also have [ORA-12262](https://docs.oracle.com/en/error-help/db/ora-12262/?ref=ggorantala.dev) for a hostname that won't resolve inside an Easy Connect string. ORA-12154 is about the *alias* lookup, one step before DNS.

**ORA-12514 right after `docker run` means the service name is wrong.** Maybe. Or the database hasn't registered with the listener yet, which takes a while after a container starts. Same code, completely different fix: a healthcheck, not a config change. That case has [its own article](https://ggorantala.dev/oracle-docker-ora-12514-not-ready/?ref=ggorantala.dev).

What I checked for this piece: Oracle's error help pages for ORA-12154, ORA-12514, ORA-12541, ORA-12545 and ORA-12262; the 26ai Net Services Administrator's Guide pages on the most common errors and on ORA-12541 specifically; the python-oracledb troubleshooting guide; and the three single-error articles this one compares, whose message wordings were checked against the same pages.

## Telling them apart in production, in under a minute

Read the code first. It's already told you which layer. Then one command per layer, run **from the machine the app runs on** (inside the app's container if it runs in one, because that's the machine whose view matters):

```bash
# ORA-12154: which naming config does this process see?
echo "TNS_ADMIN=$TNS_ADMIN"; ls -l "${TNS_ADMIN:-.}/tnsnames.ora"

# ORA-12541: is anything accepting TCP at the address in the message?
nc -vz -w 3 db-loyalty 1521     # refused fast = 12541; hangs = 12170 territory

# ORA-12514: on the database host, what services does the listener actually know?
lsnrctl services | grep -i -A2 'Service "'

```

And from any session that does connect (a DBA one is fine), what the database thinks it offers:

```sql
SELECT name, network_name, con_id FROM v$active_services ORDER BY con_id, name;

```

If the code isn't in front of you, say it's buried in a pool's log as a generic "cannot connect," time-to-fail is the tiebreaker. Instant, with no network traffic: 12154\. Fast with traffic: 12541 or 12514\. Seconds, matching your connect timeout: 12170, and you're in a different article. [Reading lsnrctl services output](https://ggorantala.dev/lsnrctl-status-services-explained/?ref=ggorantala.dev) has the line-by-line for the last step, and if the service list shows `FREE` where you expected a PDB, the [SID vs service name](https://ggorantala.dev/oracle-sid-vs-service-name/?ref=ggorantala.dev) comparison explains why that half-works.

## If a teammate asks at standup

"Which one is it?" Here's the sixty-second version:

- **12154**: your client couldn't look up the name. Nothing left the box. Fix the config on the client, or skip aliases with `//host:port/service`.
- **12541**: nothing answered on that host and port from where you are. Check the address in the message, then the listener, then the port mapping or firewall.
- **12514**: a listener answered and doesn't know that service. Wrong name, wrong PDB, a `DB_DOMAIN` suffix, or the database hasn't registered yet.

And the rule that saves the most time: never restart the database for any of these until the code tells you the listener is involved. For 12154 it can't help. For 12514 it sometimes "helps" by re-registering services, which teaches everyone exactly the wrong lesson.

## Questions that land on this page

### Is ORA-12154 a server error or a client error?

Client. It's raised by the naming layer in SQL\*Plus, Instant Client, the JDBC driver or python-oracledb before any network connection opens. Nothing on the database host can cause it or fix it, so look at `TNS_ADMIN`, the `tnsnames.ora` your client actually reads, or switch to an Easy Connect string.

### Why does tnsping succeed when I get ORA-12514?

`tnsping` only resolves the alias and checks that a listener answers at that address. It doesn't ask for the service, so it can't detect ORA-12514\. Run `lsnrctl services` on the database host and compare the service names there with the one in your connect string, including any domain suffix.

### Can a firewall cause ORA-12541 instead of ORA-12170?

Yes. A firewall that drops packets makes the connect hang until a timeout, which gives ORA-12170\. One that rejects them sends an immediate refusal, which the client can't tell apart from "no listener," so you get ORA-12541\. Test with `nc -vz` from the app's own host to see which you have.

### What's the difference between ORA-12514 and ORA-12505?

Both come from a listener that answered. ORA-12514 means it doesn't know the *service* you asked for; ORA-12505 means it doesn't know the *SID*. In JDBC the second one is nearly always `@host:port:NAME` (colon, SID) where `@//host:port/NAME` (slash, service) was meant. See the [ORA-12505 article](https://ggorantala.dev/ora-12505-listener-does-not-know-sid/?ref=ggorantala.dev) for the fix.