errors/oracle-tns.spec
Fix ORA-12154: TNS Could Not Resolve Connect Identifier
Getting this error when connecting to Oracle? It means SQL Developer can't find the database alias in your TNS configuration. Here's how to fix it.
~/errors/ora-12154.spec
diagnosis
# Error classification
error_code = ORA-12154
error_class = Oracle TNS / naming
message = TNS:could not resolve the connect identifier specified
# Where Oracle looks
config_file = tnsnames.ora
env_var = TNS_ADMIN # points to network/admin dir
also_checked = sqlnet.ora (NAMES.DIRECTORY_PATH)
fastest_fix = switch connection type to Basic
time_to_fix = 5 to 15 minutes
difficulty = Intermediate
// see "Quickest Fix" below for fastest path
explanation.txt
What ORA-12154 Means
Understanding the error.
This error occurs when Oracle can't find the TNS alias (database name) you're trying to connect to. Oracle looks for this alias in the tnsnames.ora file, and either:
- The alias doesn't exist in tnsnames.ora
- The tnsnames.ora file can't be found
- There's a typo in the alias name
- The tnsnames.ora file has syntax errors
fastest-path.spec
Quickest Fix: Use Basic Connection
Skip TNS entirely — connect directly using hostname, port, and service name. This bypasses tnsnames.ora completely.
STEP_01
Open Connection Dialog
In the Connections panel on the left side of the IDE, click the green + icon at the top of the panel header. The "New / Select Database Connection" dialog opens. In its left-side tab strip, click Oracle if not already selected.
STEP_02
Switch Connection Type to Basic
Mid-dialog, find the "Connection Type" dropdown (first selector after Username/Password). Change it from TNS to Basic. The form below swaps from a "Network Alias" picker to direct Hostname/Port/Service Name inputs.
STEP_03
Enter Direct Details
Fields top-to-bottom:
Hostname: Oracle server FQDN or IP (e.g., db.example.com)
Port: 1521 (default; change only if DBA confirmed)
Service name: e.g., ORCL, XE, or your PDB name like ORCLPDB1 — select the Service name radio, not SID
Click Test (bottom-left). Status should show Status: Success in green. Then Save → Connect.
tns/fixes.conf
If You Must Use TNS
Four checks to fix your TNS configuration so the alias resolves.
~/tns/check-1-env.sh1 · TNS_ADMIN
# SQL Developer needs to know where to find tnsnames.ora
# Windows
setx TNS_ADMIN "C:\oracle\network\admin"
# Linux / macOS
export TNS_ADMIN=/opt/oracle/network/admin
// Or in SQL Developer:
// Tools → Preferences → Database → Advanced → Tnsnames Directory
~/tns/check-2-tnsnames.ora2 · alias syntax
# A correct tnsnames.ora entry looks like this:
MYDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
// Common mistakes: missing parentheses, wrong indentation,
// spaces in alias name, SID used instead of SERVICE_NAME
~/tns/check-3-alias.txt3 · alias name match
# The connection name in SQL Developer must match the alias
# in tnsnames.ora exactly. TNS aliases are case-insensitive,
# but watch for:
issue_1 = extra spaces before/after the name
issue_2 = typos (PROD vs PRDO)
issue_3 = wrong environment (DEV vs PROD)
~/tns/check-4-tnsping.sh4 · tnsping
# From command line, test if the TNS alias resolves
$ tnsping MYDB
// If tnsping fails, the problem is in your TNS configuration,
// not SQL Developer.
PROBLEMS panel
Other ORA-12154 Causes
Less common but possible issues if the standard fixes don't apply.
-
⚠
Multiple Oracle Homes
If you have multiple Oracle installations, SQL Developer might be looking at the wrong tnsnames.ora. Explicitly set the path in SQL Developer preferences.
ENV
-
⚠
File Permissions
Make sure your user account has read access to the tnsnames.ora file. On Windows, right-click the file and check Security permissions.
FS
-
⚠
LDAP Configuration
If your organization uses LDAP for Oracle naming, check sqlnet.ora for the NAMES.DIRECTORY_PATH setting. It should include TNSNAMES.
LDAP
Still Stuck on ORA-12154?
If the Basic connection workaround and the four TNS checks above didn't help, your Oracle DBA can confirm the LDAP / TNSNAMES naming setup and the SQLNET configuration at the server level — usually a 5-minute fix once they look.