I have Oracle 9i installed on machine connected to the internet behind NAT, and the Oracle DB server is listening on default port 1521, when I connect over the LAN IP to the database server it works perfectly, and I did port forwarding on port 1521 to the private IP address in tp-link router to make the Oracle client machine connect to Oracle DB server over public IP, for example: 1521- forwarding port and its successful on canyouseeme.org but when I use this command:

SQL>connect username/password@GLOBAL_IP/service_name 
Error: ORA_12170: TNS : Connect timeout occurred 

*note: when I try to connect to the Oracle database server using Teamviewer vpn, it also works and connected so how to deal with this ?

closed as off-topic by Tom V, Kin Shah, RolandoMySQLDBA, Philᵀᴹ, Shanky Dec 17 '15 at 10:26

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    I'm voting to close this question as off-topic because this is a networking issue more than a database administration issue – Tom V Dec 16 '15 at 19:17

What is probably happening is that you have a router that doesn't support NAT loopback or the router configuration isn't properly set up.

You can connect from the outside as proven by the fact that canyouseeme.org sees you, and you can VPN into it because TeamViewer connections come from TeamViewer servers (hence the outside), and you can also connect to the internal IP.

If you want transparent connections from the inside and the outside you would need to either set up DNS, so that in your internal LAN the hostname.yourdomain.org points to the internal IP and make sure that from the outside the same hostname points to your external IP or get a router that supports NAT loopback.

There is plenty to find if you google 'nat loopback connect to external ip from lan' or you might find this post on serverfault interesting: Loopback to forwarded Public IP address from local network - Hairpin NAT


Community Wiki answer generated from answers originally left as comments on the question

Colin 't Hart: Oracle's network protocol doesn't play nicely with firewalls, especially in older versions. I believe that the client tells the server to connect back to it on a certain port -- much like the FTP protocol does -- and your firewall doesn't intercept those packets and do anything with them. I think you might be able to use Oracle's Connection Manager to get around the problem. Alternatively, you might be able to create an SSH tunnel and connect over that.

Miracle173: Define a tns name with SERVER=DEDICATED in your tnsname.ora. something like


...or use it directly

Not the answer you're looking for? Browse other questions tagged or ask your own question.