I am trying to set up an Oracle database server (at the moment just for testing purposes) in a virtual machine.

The setup I'm using:

  • VirtualBox
  • Network adapter in NAT mode (redirecting ports 22->22, 80->80, 1521->1521, 8080->8080)
    • I'd rather avoid bridged networking, if possible
    • It would be good if the database could be accessed by the outside world, and not just the host OS
  • CentOS 6.4 64-bit
  • Oracle XE, version "Production", installed and configured using the default ports (1521 and 8080)
  • Firewall disabled in both the guest OS and the host OS
  • The host OS is behind a proxy

The problem

I cannot access the database (over port 1521, using sqlplus or SQL developer) from the host. I can access it from the VM itself though (using sqlplus).

I can also SSH from the host into the VM and I can access the web interface from the host when I navigate to:

Therefore, the NAT setup of VirtualBox seems to work to some extent.

It seems the listener is up when I execute lsnctrl status. The listener.ora file looks like this:

# listener.ora Network Configuration File:

    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
      (PROGRAM = extproc)

      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))


When I try to connect from the host, I get the following error (the same command works when executed within CentOS):

PS C:\Users\winuser> sqlplus system/thepassword@

SQL*Plus: Release Production on Fr Jul 12 16:56:25 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

ORA-12154: TNS:could not resolve the connect identifier specified

Port 1521 also seems to be active in the VM, and port forwarding is set up appropriately in VirtualBox:

[root@localhost admin]# nmap

Starting Nmap 5.51 ( http://nmap.org ) at 2013-07-12 17:02 CEST
Nmap scan report for localhost.localdomain (
Host is up (0.0000050s latency).
Not shown: 994 closed ports
22/tcp   open  ssh
25/tcp   open  smtp
111/tcp  open  rpcbind
631/tcp  open  ipp
1521/tcp open  oracle
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

Thank you for any tips or suggestions.

  • Why do you want to avoid bridged networking? – Michael Hampton Jul 12 '13 at 18:18
  • Because I would like the database to be accessible when clients connect to my machine. With bridged networking, the virtual machine appears as a separate machine on the network. I'd use bridged if there is no other solution though. – Eti Jul 15 '13 at 8:00

You cannot connect to database using only IP address.


lsnrctl status

on guest machine to find out service name and instance name (ORCL for example). Then edit tnsnames.ora on host machine similar to this:


and try TNSPINGing it:

tnsping ORCL

It sould say something like "Ok (20 msec.)" At last run sqlplus:

sqlplus user/password@ORCL

For more information read Oracle Documentation: http://www.oracle.com/pls/db112/portal.portal_db?selected=4&frame=#network_management


This sounds like a problem with your Oracle network configuration. Either use network manager or hand-edit sqlnet.ora and tnsnames.ora in $ORACLE_HOME/network/admin.

  • Thanks for the info. I assume the network manager is a graphical application (the CentOS server does not have a graphical server installed)? I noticed I don't have an sqlnet.ora file, is this a mandatory file? – Eti Jul 12 '13 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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