telnet : could not open connection to host - oracle

I am trying to remotely access oracle DB using jdbc but got problems, after searching through i learned that ports might be blocked by the firewall.
I am getting the following error when i am executing the command to test if port is opened or not,
telnet MyIP 1521
Connecting to MyIP...Could not open connection to the host, on port 1521 : Connect failed
I tried opening the ports by making new inbound rule but still the error exists.
Atlast i turned my firewall off but it's still the same.
If i try the same command for localhost, i.e.,
telnet localhost 1521
It works, but using my ip address it's not.
How can i resolve this ?

Some ISP's block certain ports that might be targets for certain attacks. I know with MSSQL it uses port 1433 or something similar, and my service provider blocks connections to that port.
Try setting up your dB to use a different port than the standard and see if that works. You could also call your provider to see if they're actually blocking the port.

Configuring the connection between client and server Oracle 10g
In a comment you have an extract from lsnrctl status:
Listening Endpoints summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services summary...
Your listener is only listening on 127.0.0.1, so connections can only be made from the server. There is nothing listening on your external address 10.0.2.39, so connections to port 1521 on that address fail.
Your listener.ora presumably has something either a single ADDRESS, or no ADDRESS at all, which will default to localhost:1521. You need to modify it to something like:
LISTENER =
...
(ADDRESS_LIST =
...
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.39)(PORT = 1521))
)
or your machine's host name if that's resolvable to that address. Ideally this would be done through netca rather than by editing the file by hand.

Related

Issue connecting with local database from sql developer

I am getting the following error while connecting to a local database (After I enter the
username and password
Following are the properties for this database that I am trying to
The services 1. OracleXETNSListener 2. OracleServiceXE
are running. I am not sure what could be causing this error and I am able to connect
to local DB with sqlplus command although with a different username and password
The listener.ora has the following entry:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = L05015765)(PORT = 1521))
)
)
Also, I couldn't find any output for
netstat -aof | findstr :1521
netstat -aof | findstr :8080
netstat -aof | findstr :8082
which probably means nothing is running on 1521, and so the local connection that I
want to make it on port 1521 as per the properties window in SQL developer.
I am not sure how to debug this further and what could be going wrong
Your listener configuration shows that is listening on port 1521 on L05015765. That is your PC's name, and in network terms will presumably resolve to your LAN IP address (e.g. 192.168.0.1).
Your SQL Developer connection is to port 1521 on localhost, which is a different network adapter, which will resolve to a different private, fixed , IP address, 127.0.0.1. (Although it may not actually work at all by default on Windows, I believe).
If you change your connection to use L05015765 to match the listener configuration, you will be able to connect.

Unable to connect to Database using SQL Developer (not picking up from tnsnames.ora)

I have installed Oracle 11g & SQL Developer on my Linux Mint OS.
After setting ORACLE_PATH and relevant variable in .bashrc file, I am able to connect using sqlplus.
Snapshot of my tnsnames.ora
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
had tried with (HOST = localhost) too.
I've my localhost and IP address is mentioned in /etc/hosts file.
I've configured TNSnames directory to sql developer following below command:
tools->Preferences->Database->advanced->Tnsnames Directory (where tnsnames.ora is stored)
Set the ORACLE_HOME as :/u01/app/oracle/product/11.2.0/xe/
(Not able to connect to SQL Developer even with SYS/SYSDBA credentials)
Error I receive:
listener refused the connection ora-12514 listener does not currently know of service requested
I've tried almost every single solution by following posts of:
Google
StackOverFlow
Blogs
Other solutions
But couldn't solve my issue.
Please don't mark this question as duplicate.
I'm badly stuck at this.
EDIT: I'm trying to connect using :
1) Connection Type: Basic ; Role: Default
Hostname: Localhost; Port: 1521; SERVICE_NAME: xe
Error:
listener refused the connection ora-12514 listener does not currently
know of service requested
2) Connection Type: TNS ; Role: Default
Specifying Connect Identifier throws:
no ocijdbc12 in java.library.path
Specifying Network Alias 'XE' (choosing from drop-down menu) throws:
The network Adapter could not establish the connection
Yet I'm able to access using SYS credentials & custom user credentials from terminal- sqlplus
Finally! I am able to connect to database using SQL Developer.
(I had verified that port 1521 is opened
and was able to ping the localhost with port 1521
and It was not blocked by Firewall )
Reason I was unable to connect was No TNS listener (This I got while trying connect from SQL Command Line)
One thing I understand that running SQL*Plus from terminal does not require TNS Listener to connect.
In order to resolve, I had to replace HOST in Listener.ORA file.
From
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
To
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0) (PORT = 1521))
And then I restart the listener,
lsnrctl stop
lsnrctl start

sqldeveloper on Host - VirtualBox (NAT network) - Virtual Machine Guest (ORA 12c DB)

I have a problem with connection to ORA DB configured on Virtual Machine, where windows server 2016 is also installed.
In first configuration, I installed ORA DB 11G on Ubuntu, I opened port 1521 on Ubuntu. Virtualbox has NAT network setting and unfortunately it won't change because of administration restrictions (I won't get any new ip from bridged network,etc.). In virtual box NAT FORWARDING I set host port 2223 and guest port 1521.
Then I put a proper configuration in tnsnames in both machines (host and guest), next I connected to ORA DB on ubuntu via sql developer from the host machine using such a configuration:
UBUNTU_XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 2223))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
It works perfectly
I configured ORA DB 12C on Windows Server 2016, in firewall inbound/outbound rule I opened port 1521 for Oracle. ORA Services is running on local user name: oracle which was created before ORA installation. I logged in as user name: oracle to conduct oracle installation. In virtual box NAT FORWARDING I set host port 2225 and guest port 1521.
Then I put a proper configuration in tnsnames in both machines (host and guest), next I connected to ORA DB on Windows server (guest) via sql developer from the host machine using such a configuration:
PDB_WIN_SERV16_FORWARD_127.0.0.1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 2225))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
I tried also:
PDB_WIN_SERV16_FORWARD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2225))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb)
)
)
I want to confirm that above-mentioned connection works perfectly on Windows Server 2016 (of course with replacing port 2225 with 1521), on the other hand is not working on the host computer, the connection process in sql developer is still lasting. When I pick stop I get a communicate "Socket read interrupted, connect lapse 1857ms, authentication lapse 0 ms.
What is missing in configuration in windows server 2016 so as I could connect to ORA DB from the host?
Greetings
The problem was the same as always. Listner.ora should have listened in a static registration on 10.0.2.15 (IP in NAT configuration). Then you have to restart listener via cmd line>lsnrctl restart. After you open listener port in inbound tcp rules and set proper nat forwarding in virtual box network configuration, e.g. PORT HOST 2223 GUEST PORT 1521, you will be able to connect to ORA DB on Virtual Machine using a connection from tnsnames on host computer:
WIN_SERV16_FORWARD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2223))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb4)
)
)

getting ORA-12545 even though host name is correct

I am try to access remote database by making these changes to my tnsnames.ora file (sorry won't declare host names and service name here)
MYDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host_name)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xxxx.edu)
)
)
sqlnet.ora
# sqlnet.ora Network Configuration File: C:\app\nsm\product\12.1.0\admin\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
However,I am getting ORA-12545 and looks like hostname is not right.Actually,one other person connected to the db using the very same host name but I can't connect.Is there anything wrong with my ora file? I am using Windows.
Any help is appreciated.
I had this problem with a Windows 10 client, where both IPv6 and IPv4 were active. Apparently, it was trying to resolve the host name through IPv6 where the domain doesn't exist, instead of our IPv4 DNS.
Disabling IPv6 on the network adapter fixed the problem, until we can get the name resolution working on both 4 and 6.

connecting to database on ec2 Virtual Machine from sql developer

I am using Oracle SQL Developer 4 to connect to databases . We are running an Oracle 11g on Amazon EC2 Virtual Machine (not RDS) and I can’t connect remotely. inside the Virtual Machine as local host it work fine.
how can I set up my Virtual Machine to be able to connect remotely via sql developer to database installed on that Virtual Machine.
I encountered the same problem today and here is my configuration.
The Oracle 11g is installed on a RHEL EC2 instance and the SQL developer is installed on a Windows 2008 R2 Server instance.
We need to do these three things to fix the problem:
1) In the security group of the Amazon instances, add the inbound rules to allow connections to the Linux server. Notice that the Source IP address has to be the AWS private IP in the format of 172.31.0.0/16 instead of the public IP of 52.76.0.0/16.
2) Add the entry as below to your tnsnames.ora file:
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ec2-52-76-XX-XX.us-west-2.compute.amazonaws.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.us-west-2.compute.internal)
)
)
3) On the RHEL instance, only the ports of 22 (SSH) and 5904 (TightVNC) are opened now. We need to use the following command from ec2-user account to punch a hole in the firewall to open the port of 1521 which is used by Oracle database service.
sudo iptables -I INPUT -p tcp --dport 1521 -j ACCEPT

Resources