Status failure test failed io error the network adapter could not establish the connection

Oracle SQL is an Integrated Development Environment that was created for working on Oracle Databases with SQL. This product is developed and provided by Oracle corporation for free and it is based on

Oracle SQL is an Integrated Development Environment that was created for working on Oracle Databases with SQL. This product is developed and provided by Oracle corporation for free and it is based on the Java Development Kit. Quite recently, there have been many reports of an “IO Error: The Network Adapter Could Not Establish The Connection” Error while testing a database connection.

IO ERROR: The network adapter could not establish the connection

What Causes the “The Network Adapter Could Not Establish The Connection” Error?

After receiving numerous reports from multiple users, we decided to investigate the issue and devised a set of solutions to fix it completely. Also, we looked into the reasons due to which this error is triggered and listed them as follows.

  • Incorrect Details: Make sure that the connection details have been entered properly. The Hostname, Port, Username, and password need to be entered correctly in order to establish the connection. If any of these values aren’t entered properly, the error might be triggered.
  • Disabled Service: It is very important that the listener service has been started in the background for the application to work properly, If it hasn’t been started or is disabled, this error might be triggered.

Now that you have a basic understanding of the nature of the problem, we will move on towards the solutions. Make sure to implement these in the specific way in which they are presented to avoid conflict.

Solution 1: Checking Details

It is important that the correct details have been entered for the connection. Sometimes, the details entered don’t match the server configurations and the error is triggered. Therefore, in this step, we will be checking and entering the details again. For that:

  1. Download and install Notepad++ from here.
  2. Navigate to the following address.
    DB Home: C:/app/Username/product/11.2.0(version might differ)/dbhome_1/Network/Admin

    Navigating to the address
  3. Right-click on the “tnsnames.ora” file and select “Open With Notepad ++” option.
    Right-clicking on the file and selecting “Open With Notepad++”
  4. Under the “ORCL=” heading, note the “Port” and the “Host” details.
  5. Also, note the “Service Name“.
    Noting down the details
  6. Enter these details while establishing the network connection and click on “Test“.
  7. Check to see if the issue is solved.

Solution 2: Starting Listener Service

It is possible that the listener service hasn’t been started. This service is required by the application in order to establish a connection. Therefore, in this step, we will be starting the service by entering a command in the Command prompt. For that:

  1. Press “Windows” + “R” to open the Run prompt.
  2. Type in “Cmd” and press “Shift” + “Ctrl” + “Enter” to provide adminsitrative privileges.
    Typing cmd in the Run Prompt and pressing “Shift”+ “Ctrl” + “Enter”
  3. Type in the following command to check if the service is started.
    lsnrctl status
  4. If the result is similar to the image below, it means that the service hasn’t been started.
    This message is displayed if the service hasn’t been started
  5. Enter the following command to start the service manually.
    lsnrctl start

    Typing in the command to start the service
  6. Now that the listener service has been started, open the application and check to see if a new connection can be established.

Photo of Kevin Arrows

Kevin Arrows

Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Back to top button

SQL Developer is an Integrated Development Environment (IDE) for developing SQL in Oracle database. This is a free tool from Oracle which is used by both developer and database administrator. This article assumes that you have an Oracle database installed on a Linux server. You have installed SQL Developer to connect to the database. SQL Developer requires a minimum of  host name or IP, port, and a database SID and a database user account to make the connection to the database.

Sometime all the information required to make a connection to SQL Developer  are provided even then the connection failed with an error message. This is the most common issue I see with a new Oracle database set up or when something changes on server side. Let’s find out all the breaking points, test them and fix the connection.

 See error message!

Displaying image.png

 status: failure — test failed: IO Error: The network Adapter could not establish the connection
We are now going to troubleshoot this connection issue. Some may know the answers but with this article, we will explore and verify everything that makes this connection. What are few things you need for this connections to succeed beside Oracle user account, host/port and SID?

Verify each listed below for successful connection.

  1. Database host  is up
  2. Oracle SID name
  3. Oracle database is open
  4. Oracle Listener is listening
  5. listening port (1521) 
  6. Oracle user account

Next, we are going to verify each of the above listed steps.

  1. Ping host IP 192.168.1.120  from your pc cmd. This test if the host where the database is installed is up or not.  # verified,
  2. Echo $ORACLE_SID  # verified the name of SID
  3. On sqlplus run ( select status from v$instance;)  # verified the database is open and running
  4. LSNRCTL status  # verified the listener is listening for the above SID
  5. Verify port 1521 is the listening port # verified the listening port
  6. Able to connect to database using the user credential via SQLPlus. 


The listener is up and listening at port 1521

oracle@oracldev etc]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 — Production on 12-JUL-2015 13:25:12
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracldev.baniya.com)(PORT=1521)))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 — Production
Start Date                12-JUL-2015 13:15:00
Uptime                    0 days 0 hr. 10 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracldev/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracldev.baniya.com)(PORT=1521)))
Services Summary…
Service «DEV» has 1 instance(s).
  Instance «DEV», status READY, has 1 handler(s) for this service…
Service «DEVXDB» has 1 instance(s).
  Instance «DEV», status READY, has 1 handler(s) for this service…
The command completed successfully
[oracle@oracldev etc]$

The database is up and mounted

QL> select status from v$instance;
STATUS
————
OPEN
SQL>

The host name and port on tnsname.ora

[oracle@oracldev admin]$ cat listener.ora
# listener.ora Network Configuration File:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora                                                   # Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracldev.baniya.com)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

Host Name and IP verified.

[oracle@oracldev ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.120 oracldev.baniya.com

Pinging to 192.168.1.120

Displaying image.png

Everything is verified, the host and oracle database is up but still cannot connect to database using SQL Developer.

  1. Ping host IP 192.168.1.120  from your pc cmd. This test if the host where the database is installed is up or not.  # verified,
  2. Echo $ORACLE_SID  # verified the name of SID
  3. On sqlplus run ( select status from v$instance;)  # verified the database is open and running
  4. LSNRCTL status  # verified the listener is listening for the above SID
  5. Verify port 1521 is the listening port # verified the listening port
  6. Able to connect to database using the user credential via SQLPlus. 

Why is the connection still hesitant? What did we miss to the above list?The only thing we didn’t check was the firewall on the Linux host.  We will first try to disable the firewall if that works we know the problem. Connect to Linux host and disable firewall. You will need to have a root access to make this change.

  1. service iptables stop 
  2. service iptables status

Disabling firewall fixed the connection problem that we are having.  Note that disabling a firewall in a production environment isn’t a good security practice, therefore you will need to open a port 1521 on your Linux server. Below, I will should you how you can open port 1521 on a Linux OS.


How to open port 1521 on linux server?

iptables -A INPUT -m state —state NEW -m tcp -p tcp —dport 1521 -j ACCEPT
service iptables save
open file /etc/sysconfig/iptables:
# vi /etc/sysconfig/iptables
and put the below line of code just above the RECJECT code
-A INPUT -p tcp -m state —state NEW -m tcp —dport 1521 -j ACCEPT
service iptables restart
Check if the rule of 1521 is active
iptables -L -n | grep 1521

The port 1521 is now open on the firewall. This resolved SQL Developer connection issue.

You should be connected by now if you are using a basic thin client connection. The FAT client connection may required some additional troubleshooting steps which we will discuss on next article.

Interested in working with me? I can be reached at pbaniya04[at]gmail.com for any questions, consulting opportunities or you may drop a line to say HELLO. Thank your again for visiting my blog and looking forward to serving you more.

Have a Database-ious Day!

Hey guys! Have you ever faced the TNS IO error saying “The network adapter could not establish the connection”? when you are trying to make a new connection in SQL Developer or logging on to the database using SQL*Plus editor. If yes then you are at the right place because here in this blog I am going to show you how you can solve this error. 

sql error the network adapter could not establish connection by manish sharma

So without further ado let’s proceed to solve this badass TNS error.

Step 1: Make sure your entries are correct

First of all to solve “The network adapter could not establish the connection” error, check whether you have entered the correct username and password as well as the correct Hostname and Port number. Though these are small things we cannot avoid them. After all “It’s the small things in a relationship that means the most.” 

[bctt tweet=”How to solve “The network adapter could not establish the connection” error in just 2 steps” username=”RebellionRider”]

For the valid hostname and port number, you can check the Listener.ora if you have access to your server as the listener is a server process. In case you don’t have access to listener.ora file then you can check the tnsnames.ora file.

In case of Listener.ora file check for Host and Port entry in Listener tag for valid hostname and port number. 

sql error the network adapter could not establish connection by manish sharma

Listener.ora

And if you are using TNSnames.ora file for validating the hostname and port number then search for the entry which has the same name as your SID and then check for host and port number entry in that particular tag.

sql error the network adapter could not establish connection by manish sharma

TNSnames.ora

Now try connecting. If this solves your problem then you can avoid the next step. But if “The network adapter could not establish the connection” error is still there, then don’t worry just follow the next step.

Step 2: Is your listener taking a rest?

If your problem is still there and you haven’t gotten rid of that nasty error then there is a possibility that your Listener is not running. To check whether Listener is up and running or not, simply open up your command prompt with Administrative privileges and Write 

C:> lsnrctl status

This command will show you the status of your listener. If the output of this command looks like the one shown in the picture below then it clearly means your listener is not running thus next what you have to do is to start the listener. 

sql error the network adapter could not establish connection by manish sharma

To start the listener you just have to write

C:> lsnrctl start.

This will start your listener and most probably solve your problem.

Info Byte:
In case you are having problems in starting your listener then try starting “OracleOraDb11g_home1TNSListener” windows service. For that open your Run Command and write services.msc this will open your service panel. Here search for the same and right click to start it.

That’s all you have to do. This must solve the “The network adapter could not establish the connection” error. May the force be with you. Enjoy.

Also, click here to learn how to do initial configuration of Orcale Enterprise Manager to start working with it. 

If you find this helpful then please do share it on your social network and help me reach out to more people. Also if you have other queries then reach out to me on my Facebook Page & Twitter. Thanks, guys & have a great day!

SQL Developer FAQ

One of the hardest parts about learning Oracle SQL is getting the database connection working.

After you download Oracle (either Oracle Express or the full database), and an IDE of your choice (such as SQL Developer), it should be easy to set up a new connection and log in.

However, it’s not.

By far, the most common question I receive in my Introduction to Oracle SQL course is how to connect to the database. There were quite a few steps involved in 11g, but now that Oracle Express has released 18c, there are a few more issues that appear.

This article explains what Oracle connection issues may occur and how to fix them.

Errors You Might Get When Connecting to Oracle

Here are some of the errors you might get when trying to connect to an Oracle 12c or 18c database.

Invalid Common User or Role Name

ORA-65096: invalid common user or role name
65096. 00000 -  "invalid common user or role name"
*Cause:    An attempt was made to create a common user or role with a name
that was not valid for common users or roles.  In addition to
the usual rules for user and role names, common user and role
names must start with C## or c## and consist only of ASCII
characters.
*Action:   Specify a valid common user or role name.

IO Error

Status : Failure - Test failed: IO Error : 
The network Adaptor could not establish the connection.

User Does Not Exist

ORA-01917: user or role 'INTRO_USER' does not exist
1917. 00000 -  "user or role '%s' does not exist"
*Cause:    There is not a user or role by that name.
*Action:   Re-specify the name.

SID Unknown

ORA-12505 error. TNS: listener doesn't know of SID given in connect descriptor.

Invalid Username/Password

ORA-01017: invalid username/password; logon denied

As you can see, there are quite a few different errors you can get when attempting to connect to an Oracle database.

Solutions to Oracle Database Connection Issues

Here are the solutions to the connection issues. I’ve listed them briefly here, and more details are available below.

  1. Ensure the Oracle Database is running
  2. Use the correct SID or Service Name for Pluggable Databases
  3. Login to the system accounts correctly
  4. Passwords are case sensitive

Ensure the Oracle Database is running

The first thing to do is to check that the Oracle database is running.

It should be running by default, but it’s an easy thing to check and nothing will work if the database isn’t running.

Sometimes I’ve noticed the database isn’t running if I restart my computer or have some other issue.

To start the Oracle database:

  1. Go to Start > Oracle
  2. Click on Start Oracle Database
  3. A command window is opened which runs Oracle database. Once it closes, the database should be running

You can check it is running by right-clicking the Start menu and selecting Services.

Scroll down to Oracle and check that the Oracle Database entry is set to Running.

Ensuring Oracle is running will sometimes resolve the following errors:

  • Status : Failure – Test failed: IO Error : The network Adaptor could not establish the connection.
  • ORA-12505 error. TNS: listener doesn’t know of SID given in connect descriptor.

If you still get these errors, there are more steps you can try.

Use the correct SID or Service Name for Pluggable Databases

In Oracle 11g and prior versions, when you installed Oracle/Oracle Express, you got one database.

However, as of 12c (so in versions 12c, 18c, and 19c), a concept was introduced called “container and pluggable databases”.

It allows for a set of rules and standards to be applied to a “container database”, which is kind of like a template or a parent database.

The “pluggable database” is where the real action happens. This is where data is stored and users are meant to be created. It inherits some information from the container database.

It’s kind of like the inheritance concept in object-oriented programming (if you’re familiar with that).

You can read more about this here: A Guide to PDBs and CDBs.

Why do you need to know about this?

Because, if you attempt to create a new user on the container database, you’ll get an error that doesn’t make any sense:

ORA-65096: invalid common user or role name
65096. 00000 -  "invalid common user or role name"
*Cause:    An attempt was made to create a common user or role with a name
that was not valid for common users or roles.  In addition to
the usual rules for user and role names, common user and role
names must start with C## or c## and consist only of ASCII
characters.
*Action:   Specify a valid common user or role name.

So why are you getting this “ORA-65096: invalid common user or role name” error?

Because you are attempting to create a new user on the container database. The solution is to create this new user on the pluggable database.

How do you create a new user on the pluggable database?

You need to log in to the pluggable database and create the user from there.

So, if you get this error:

  • Create a new connection to the pluggable database using an existing user (e.g. SYS)
  • Connect using this new connection
  • Run the Create User command
  • Create a new connection with the new user.

Step 1: Create a new connection to the pluggable database

In SQL Developer, create a new connection. In the new connection window, enter the following details:

  • Name: any name you want to use for your connection.
  • Username: SYS (or a user that has administrative rights)
  • Role: SYSDBA (if the username entered is SYS)
  • Password: the password for this account
  • Host: the location of your database, such as “localhost”
  • Port: 1521 (the default)

New Oracle Connection as SYS

Change the radio button from SID to Service Name, and enter a Service Name of XEPDB1.

This assumes you’re running Oracle Express. If not, your Service Name will be something different.

Entering this Service Name will let you connect to the pluggable database.

Test your connection, and if it is successful, save the connection.

Step 2: Connect

Now your new connection is created, it’s time to connect to it.

Right-click on the connection in the Connection panel on the left and select Connect.

Right click and connect to Oracle

You’ll then be connected to the database, and a new SQL window will open, allowing you to run commands.

Step 3: Run the Create User command

Now that you are connected to the database as an administrator (e.g. SYS), you can now create a new user.

For a new user to connect to a database, it needs to have a few privileges:

  • Connect
  • Create Session
  • Tablespace

I also like to give it Create Table privileges, so it can actually create tables.

Here’s the code to create a new user:

CREATE USER intro_user IDENTIFIED BY mypassword;
GRANT CONNECT TO intro_user;
GRANT CREATE SESSION, GRANT ANY PRIVILEGE TO intro_user;
GRANT UNLIMITED TABLESPACE TO intro_user;
GRANT CREATE TABLE TO intro_user;

Replace the username “intro_user” with whatever you want your username to be, and the “mypassword” with whatever password you want.

Run this code, and the new user is created.

Step 4: Connect as the New User

Finally, with the new user created, it’s time to create a new connection with this new user. This is the connection you can use each time you access the Oracle database.

It’s a similar process to step 1. Create a new connection in SQL Developer:

  • Name: any name you want to use for your connection.
  • Username: the username you added in Step 3
  • Password: the password for this account that you specified in step 3
  • Host: the location of your database, such as “localhost”
  • Port: 1521 (the default)
  • Service Name: XEPDB1

New Oracle connection as regular user

Test that the connection works, and save the connection.

You can now connect to this database and run SQL.

Login to System Accounts Correctly

I’ve had a few issues when attempting to login to the system accounts on my Oracle Express database before.

The errors have happened because I’ve entered the wrong information when trying to connect.

With Oracle Express, your system accounts need to connect as SYSDBA and also connect to the pluggable database (Service Name = XEPDB1).

As mentioned above, the connection details are:

  • Name: any name you want to use for your connection.
  • Username: SYS (or a user that has administrative rights)
  • Role: SYSDBA (if the username entered is SYSTEM)
  • Password: the password for this account
  • Host: the location of your database, such as “localhost”
  • Port: 1521 (the default)
  • Service Name: XEPDB1

New Oracle Connection as SYS

This should resolve any other issues you have when connecting to Oracle.

Passwords are Case Sensitive

In Oracle 12c, passwords were made case-sensitive. This means that a password of “february” is different from “FEBRUARY”.

This can be a bit of a surprise if you’re updating from the previous version of Oracle Express, which was 11g, and did not have case-sensitive passwords.

When you enter your password into the connection window, or when you create a user, be mindful of the case you are using.

Be Careful of _ORACLE_SCRIPT

Several suggestions online involve the user of a database parameter called _ORACLE_SCRIPT.

Let’s say you get this error message:

ORA-65096: invalid common user or role name
65096. 00000 -  "invalid common user or role name"
*Cause:    An attempt was made to create a common user or role with a name
that was not valid for common users or roles.  In addition to
the usual rules for user and role names, common user and role
names must start with C## or c## and consist only of ASCII
characters.
*Action:   Specify a valid common user or role name.

One of the more popular solutions online is to run this command, and then try again:

ALTER SESSION SET "_ORACLE_SCRIPT"=TRUE;

This is a database session parameter that seems to resolve your issue.

However, it’s an undocumented feature. This means the behaviour of this is not supported and could change at any time.

Rather than using undocumented features, it’s better to follow the process above by creating a new user on the pluggable database. It takes a few more steps, but it’s the right way to do it, and you won’t see any strange side effects.

Conclusion

Connecting to Oracle databases can be confusing, especially if you’re just getting started with Oracle SQL and just want it to work. This post highlights a few common issues and resolutions to them.

If you have any other issues connecting to an Oracle database, let me know in the comments below.

Понравилась статья? Поделить с друзьями:
  • Status error errors message could not find attached object code 0
  • Status error errors message bad permission could not read this file code 0
  • Status error bitrix environment
  • Status err 0xc0010001 flash tool как исправить
  • Status device power failure как исправить на windows 10