title: How come sqlplus not connecting?
body: <p>My goal is to connect to an Oracle 9i instance from my OS X machine. I've followed the setup instructions <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/" rel="nofollow noreferrer">here</a> and got through them with no errors (eventually). However, I'm finding that sqlplus is unable to connect:</p>
  
  <pre><code>[ ethan@gir ~ ]$ sqlplus xxx/yyy@zzz
  
  SQL*Plus: Release 10.2.0.4.0 - Production on Fri Apr 17 10:13:08 2009
  
  Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
  </code></pre>
  
  <p>Looooong wait...</p>
  
  <pre><code>ERROR:
  ORA-12170: TNS:Connect timeout occurred
  
  Enter user-name: xxx
  Enter password: 
  ERROR:
  ORA-12162: TNS:net service name is incorrectly specified
  
  Enter user-name:
  </code></pre>
  
  <p>My <code>tnsnames.ora</code> file...</p>
  
  <pre><code>zzz =
    (DESCRIPTION = 
      (ADDRESS_LIST =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = dbhost)
          (PORT = 1521))
      )
    (CONNECT_DATA =
      (SERVICE_NAME = zzz)
    )
  )
  </code></pre>
  
  <p>Maybe there's an env variable that needs to be set?</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>Able to ping DB host machine no problem.</p>
  
  <p>Tried...</p>
  
  <pre><code>sqlplus xxx/yyy@//dbhost/zzz
  </code></pre>
  
  <p>Got...</p>
  
  <pre><code>ERROR:
  ORA-12170: TNS:Connect timeout occurred
  </code></pre>
  
  <p>Tried using <code>SID</code> instead of <code>SERVICE_NAME</code> in tnsnames.ora. Did not seem to change the result. Reverted back to <code>SERVICE_NAME</code>.</p>
  
  <hr>
  
  <p>Last couple entries in sqlnet.log...</p>
  
  <pre><code>***********************************************************************
  Fatal NI connect error 12170.
  
    VERSION INFORMATION:
      TNS for MacOS X Server: Version 10.2.0.4.0 - Production
      TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production
    Time: 17-APR-2009 10:33:06
    Tracing not turned on.
    Tns error struct:
      ns main err code: 12535
      TNS-12535: Message 12535 not found; No message file for product=network, facility=TNS
      ns secondary err code: 12560
      nt main err code: 505
      TNS-00505: Message 505 not found; No message file for product=network, facility=TNS
      nt secondary err code: 60
      nt OS err code: 0
  
  
  ***********************************************************************
  Fatal NI connect error 12170.
  
    VERSION INFORMATION:
      TNS for MacOS X Server: Version 10.2.0.4.0 - Production
      TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production
    Time: 17-APR-2009 11:24:08
    Tracing not turned on.
    Tns error struct:
      ns main err code: 12535
      TNS-12535: Message 12535 not found; No message file for product=network, facility=TNS
      ns secondary err code: 12560
      nt main err code: 505
      TNS-00505: Message 505 not found; No message file for product=network, facility=TNS
      nt secondary err code: 60
      nt OS err code: 0
  </code></pre>
  
  <hr>
  
  <p>PARTIAL ANSWER</p>
  
  <p>Thanks everyone for your answers. They were helpful. I found that there was a DNS issue. I was able to ping by hostname, so thought that should work fine. I also tried I.P. address. Turned out that I needed the <strong>internal</strong> "10.1.x.x" I.P. address for it to work on this OS X machine (but hostname is fine on Windows).</p>
  
  <p>At this point, I can connect with...</p>
  
  <pre><code>sqlplus xxx/yyy@//INTERNAL_IP/zzz
  </code></pre>
  
  <p>However, with those values entered into tnsnames.ora, this still doesn't work...</p>
  
  <pre><code>sqlplus xxx/yyy@zzz
  </code></pre>
  
  <p>...</p>
  
  <pre><code>ORA-12154: TNS:could not resolve the connect identifier specified
  </code></pre>
  
  <hr>
  
  <p>I searched for a sample tnsnames.ora file that was close to what I needed and copied the contents into my file. Changed the params and now everything works. Not sure why mine wasn't working.</p>