On oracle server i can connect clear

sqlplus  user/pass@hostremote/SID

If i make a tunnel

ssh -L 1521:localhost:1521 -F -n hostremote -vvv

give me

debug1: Connection to port 1521 forwarding to localhost port 1521 requested.
debug2: fd 7 setting TCP_NODELAY
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
channel 2: open failed: connect failed: Connection refused
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 1521 for localhost port 1521, connect from port 60882 to port 1521, nchannels 3
debug3: channel 2: status: The following connections are open:

ORA-12537: TNS: connection close


Usually i do ssh tunnel on directly connected server,for example


On client i make the tunnel and connect with sqlplus on localhost,easy.

The situation now is a little different and more complex

ORACLESERVER=virtual machine

I have make a DNAT on VIRTUALMACHINE,i can use telnet 1521 VIRTUALMACHINE and tcptraceroute 1521 return succesfully connection. But after tunnel(succesfully) i have TNS error and no connection.

This is the dnat make with firewalld

 forward-ports: port=1521:proto=tcp:toport=1521:toaddr=

2 Answers 2


The issue is that Oracle opens additional connections, not to port 1521, after the initial connection, so your tunnel won't work this way. Set up Oracle Connection Manager on the server side so you can do all your talking to it and have it do multiple connections inside the server network.

Oracle docs (not public): https://support.oracle.com/rs?type=doc&id=Note:361284.1 Open, uhh, mirror: http://blog.itpub.net/161195/viewspace-1053131/

  • Oracle TCP protocol is not wired. In some situations it behaves similarly as FTP. e.i. it might open additional TCP connections on dynamically allocated port.

  • Oracle TCP protocol uses OOB bit in TCP header. This sometimes might cause problems when wrapping TCP into TCP.

Most probably you have problems with the 1st one point. Use strace/tcpdump to find out whether sqlplus is trying to open 2nd connection.

  • I forgot to add something about network situation, i add now,usually i do ssh tunnel sucessfully on simple net connection(direct)
    – elbarna
    Nov 16, 2015 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .