Search code examples
oracle-databaseoracle10goracle-xe

How can I run Oracle XE on localhost only?


Is there a way that I can configure a XE installation on Windows to only use ports on the localhost interface and not the external interfaces? I'd like to run it for development without having anyone else be able to connect to my instance.

I tried modifying the listener.ora and tnsnames.ora file, changing the 'HOST =' entries to localhost. My hosts file has the following line in it:

127.0.0.1 localhost

When I've done this, and restarted the services, apex stops working (it doesn't listen on port 8080) and I'm unable to connect to the database using JDBC. I get the following error with JDBC:

Exception in thread "main" java.sql.SQLException: Listener refused the connection
with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect
descriptor
The Connection descriptor used by the client was:
localhost:1521:XE

I should note that both apex and JDBC work fine if I change the 'HOST = entries back to my machines hostname and restart the services.


Solution

  • There are two parts for this (because there are two 'technologies' serving different ports).

    Firstly the listener for database port 1521. You use a SQLNET.ORA setting (tcp.invited_nodes) as a soft firewall, so the listener will ignore other nodes.

    Secondly, for the 8080 PL/SQL gateway you need to use DBMS_XDB.SETLISTENERLOCALACCESS as described here