IO Error: The Network Adapter could not establish the connection
Asked Answered
L

14

47

I am new to Oracle, and am trying to run a simple example code with Java, but am getting this error when executing the code.. I am able to start up the listener via CMD and am also able to run SQL Plus. Can anyone give me a hand and tell me what I might be doing wrong?

Update: I am using JDBC.

Database is local, and I actually had it working but it stopped working just today. I'm not really sure why though. Would you mind giving me some procedures to follow by since I don't know much.

Lumen answered 24/9, 2012 at 23:38 Comment(2)
You'll need to post your code that is producing this errorEntirely
@EJP Yes sir! Updated post to reflect so!Lumen
A
53

Either:

  1. The database isn't running
  2. You got the URL wrong
  3. There is a firewall in the way.

(This strange error message is produced by Oracle's JDBC driver when it can't connect to the database server. 'Network adapter' appears to refer to some component of their code, which isn't very useful. Real network adapters (NICs) don't establish connections at all: TCP protocol stacks do that. It would have been a lot more useful if they had just let the original ConnectException be thrown, or at least used its error message and let it appear in the stack trace.)

Annmaria answered 25/9, 2012 at 1:3 Comment(2)
How do I make sure my database is running?Lumen
@Lumen Via the utilities provided by the vendor for the purpose.Annmaria
I
10

I had the same problem, and this is how I fixed it. I was using the wrong port for my connection.

private final String DB_URL  = "jdbc:oracle:thin:@localhost:1521:orcll"; // 1521 my wrong port
  • go to your localhost
  • (my localhost address) : https://localhost:1158/em

  • login

    • user name
    • password
    • connect as --> normal
  • Below 'General' click on LISTENER_localhost

  • look at you port number
    • Net Address (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522)) Connect to port 1522
  • Edit you connection change port 1521 to 1522.

    • done
Instrumentalism answered 6/11, 2012 at 6:5 Comment(2)
I got the same problem because I forgot the @Midtown
+1. i had the same problem. I forgot the @. Example: JDBC_STRING="jdbc:oracle:thin:@aravindr-dra0r0.cyrbi4kznovv.us-west-1.rds.amazonaws.com:8195:DRA0R0"Rundlet
L
4

I resolved my issue by simply starting the TNS listener service. It was stopped for some reason. enter image description here

Laurielaurier answered 1/8, 2023 at 19:17 Comment(1)
Thank you this worked for me. When I tried to run TNS Listener it says TNS Listener started and stopped, this was fixed by deleting wrong pointing ORACLE_HOME environment variable.Harsh
F
3

Another thing you might want to check that the listener.ora file matches the way you are trying to connect to the DB. If you were connecting via a localhost reference and your listener.ora file got changed from:

HOST = localhost

to

HOST = 192.168.XX.XX

then this can cause the error that you had unless you update your hosts file to accommodate for this. Someone might have made this change to allow for remote connections to the DB from other machines.

Ferrosilicon answered 19/11, 2012 at 17:52 Comment(0)
O
1

I figured out that in my case, my database was in different subnet than the subnet from where i was trying to access the db.

Olecranon answered 11/4, 2017 at 17:0 Comment(0)
H
1

I had this error when i renamed the pc in the windows-properties. The pc-name must be updated in the listener.ora-file

Hemelytron answered 4/2, 2019 at 22:39 Comment(0)
G
1

IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=iKQM6lBbSLiArrYuDqud8A==)

if you are facing this issue 1- make sure you have downloaded oracle databases like oracle 11g,19c, 21c, or any latest databases. 2- search for services in your computer or type win+r then services.mis then search for oracleservice you will find orcl or xe or any other sid like oracleserviceorcl;

after that you can test your connection using sql developer, sql plus or cmd

Gains answered 26/6, 2022 at 0:37 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Sulemasulf
D
0

Most probably you have listener configured wrongly, the hostname you specify in connection string must be the same as in the listener.

First check the Firewall and network related issues.

Check if Oracle Listener service is available and running. If not you may use Oracle Net Configuration Assistant tool to add and register new listener.

If the above steps are ok then you need to configure Oracle Listener appropriately. You may use Oracle Net Manager tool or edit “%ORACLE_HOME%\network\admin\listener.ora” file manually.

There are 2 options that need to be considered carefully: Listening Locations associated with the Listener – Hostname(IP) and Port in Listening Location must exactly match the ones used in the connection string.

For example, if you use 192.168.74.139 as target hostname, then there must be Listening Location registered with the same IP address.

Also make sure the you use the same SID as indicated in Database Service associated with the Listener.

https://adhoctuts.com/fix-oracle-io-error-the-network-adapter-could-not-establish-the-connection-error/

Drink answered 26/8, 2018 at 14:17 Comment(1)
Hello. While posting some link is okay, we prefer them being posted with some explanation and some excerpt of the source, please read How to Answer and improve your answer.Bernhardt
P
0

In my case this happened in SOA (Oracle Weblogic) because the database tablespace was at its limit and in addition the machine's network adapter in OCI was intermittent, it was only resolved after restoring the machine's boot backup from a week ago and extend the tablespace.

Stack simplified
####<Jun 25, 2024 3:20:58 PM BRT> <Warning> <JDBC> <Unknown> <pip02> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <0000P1GcDzu1f_OLqix0iY1aUkdg000002> <1719339658829> <BEA-001129> <Received exception while creating connection for pool "mds-soa": IO Error: The Network Adapter could not establish the connection> 
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
Caused By: oracle.net.ns.NetException: The Network Adapter could not establish the connection
Caused By: java.net.ConnectException: Connection timed out (Connection timed out)
Palpate answered 25/6, 2024 at 22:59 Comment(0)
T
-1

To resolve the Network Adapter Error I had to remove the - in the name of the computer name.

Tongue answered 24/6, 2013 at 11:45 Comment(0)
B
-1

In my case, I needed to specify a viahost and viauser. Worth trying if you're in a complex system. :)

Brushoff answered 12/5, 2014 at 8:25 Comment(0)
H
-1

For me the basic oracle only was not installed. Please ensure you have oracle installed and then try checking host and port.

Hanukkah answered 28/2, 2017 at 7:31 Comment(0)
G
-1

I was having issues with this as well. I was using the jdbc connection string to connect to the database. The hostname was incorrectly configured in the string. I am using Mac, and the same string was being used on Windows machines without an issue. On my connection string, I had to make sure that I had the full url with the appending "organizationname.com" to the end of the hostname.

Hope this helps.

Gustave answered 4/6, 2019 at 22:42 Comment(0)
P
-2

Just try to re-create connection. In my situation one of jdbc connection stopped working for no reason. From console sqlplus was working ok. It took me 2 hours to realize that If i create the same connection - it works.

Potbellied answered 13/3, 2020 at 5:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.