How do you use telnet to check a connection to Oracle?

Ethan picture Ethan · Apr 18, 2009 · Viewed 85.9k times · Source

I've been trying to get sqlplus to connect to Oracle from my OS X machine. I asked another question about it here.

One person suggested that I try telnet. Consulting the man page, I tried:

[ ethan@gir ~ ]$ telnet DBHOST:1521
Trying xxx.xxx.xxx.xxx...
telnet: connect to address xxx.xxx.xxx.xxx: Operation timed out
telnet: Unable to connect to remote host

Also...

[ ethan@gir ~ ]$ telnet DBHOST 1521

...with same result.

I'm not sure how to interpret these results. Seems like what you'd expect in any case. You wouldn't do this...

$ ssh some_mysql_host:3306

How is telnet to Oracle different?

Or maybe I didn't understand what they meant.

If anyone could help me understand how one uses telnet to test a connection to Oracle I would be grateful.

Answer

Alnitak picture Alnitak · Apr 18, 2009

They're proposing use of telnet simply because it's one of the simplest TCP/IP clients and because it's installed almost everywhere. It's just an easy way to check from the command line whether you're actually able to make a TCP/IP connection to any particular service.

Also, on many of the ASCII based IP protocols it's straight forward to actually interact with the server to check its working by typing in commands and looking at the responses - I've done this numerous times myself with SMTP servers.

In your case, as you're getting a timeout, either the whole host is down, or the access to that particular host or service is being blocked by a firewall. If you can reach the server with a ping then the latter is more likely.

There's also an outside chance that your name resolution is actually taking you to the wrong host, but you should be able to confirm that by looking at the IP address that telnet said it was trying to connect to.

Another common response is "connection refused". That means that the host is up, but that there's no service running on the specified port.