Cant connect to database with ODP.NET Core on Linux — oracle-tech

    Forum Stats

  • 3,716,133 Users
  • 2,242,960 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cant connect to database with ODP.NET Core on Linux

Anthony F
Anthony F Member Posts: 7
edited August 2018 in ODP.NET

I am trying to write my first .Net Core web app and I cant seem to get it to talk to our Oracle database on my Linux VM. The same code works from my Windows desktop. The VM can see the corporate network and internet (I can browse the internet and intranet just fine). I can ping the Oracle server from the VM. I'm pretty sure the firewall isn't blocking the outgoing connections (I can SSH to various web servers in the company).

I am getting the error "ORA-12545 Network Transport: Unable to resolve correct hostname" and the underlying error is "ExtendedSocketException: No such device or address" when I try to make the connection to our database. I have put the TNS descriptor in the OracleConfiguration.OracleDataSources.Add() function on the application startup to ensure it has all the info it needs to connect to the database. The server name in the TNS description is fully qualified (, and I've also tried with IP addresses. Again the same exact code works on Windows so I'm a little lost on why it isn't working on Linux.

The rest of the application works fine - I can serve dynamic web pages, static content, etc.

I am not as experienced with Linux as I am Windows, so if I missed something in the underlying Linux config that might be it.

Server: CentOS 7

.NET Core 2.1

Oracle Managed Driver beta 3 (via nuget)

Oracle 12c

Apache httpd reverse proxy to Kestrel running the dotnet core application


  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,753 Employee
    edited August 2018

    One thing to check is to make sure the port (e.g. 1521) you are using for DB connectivity is not being blocked by the VM. You may want to go as far as installing the Oracle Client or thin JDBC on the VM to test connectivity. If you hit the same error, then it's likely to be a VM or Linux network configuration issue.

    FWIW, you can turn on tracing and email the trace to dotnet_us (at) My team can take a look to see if there's anything on the ODP.NET Core end that could be the problem, but it's more likely to be some network configuration issue.

    Here's sample code on how to setup ODP.NET Core tracing. Use level 7.

  • Anthony F
    Anthony F Member Posts: 7
    edited August 2018

    I sent in the email with the trace info this morning.

    I did check I can SSH to the oracle server on the specified host and port the listener is on. Debug messages indicate that a connection is made. I disabled SELinux as well.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,753 Employee
    edited August 2018

    I can't pinpoint an exact problem from the trace specifically. I would recommend using the IP address instead of the hostname, then trying to connect. An ORA-12545 error basically means it can't find the DB service you have defined in the connect descriptor. If the DB is up and running, then the issue likely has something to do with the network or how you interface with the network via the VM.

    Making that change to an IP resolved another user's ORA-12545, though that person was using containers and you are using a VM.

    Oracle.ManagedAccess.Client in .NET Core application running in Docker Linux Container

  • Anthony F
    Anthony F Member Posts: 7
    edited August 2018

    I finally got a chance to change it to IP address and I got the same result. It is still failing on the System.Net.Dns.InternalGetHostByName call. Not quite sure why it is trying to resolve an IP address string like its a hostname. "No such device or address" is the error at that level.

    I even went in and disabled ipv6.

  • Alex Keh-Oracle
    Alex Keh-Oracle Posts: 2,753 Employee
    edited August 2018

    Which VM software are you using? My suggestion for next steps would be to google common VM networking Oracle issues to see if others have run into a similar problem. My suspicion is that this problem is not ODP.NET Core-specific. It likely affects other Oracle Client connecting from VMs.

    The problem could CentOS itself, but I doubt it. Oracle hasn't tested ODP.NET Core on CentOS, but being so similar to RHEL, ODP.NET Core likely works on CentOS without issues.

  • Anthony F
    Anthony F Member Posts: 7
    edited August 2018

    Hi Alex.

    I checked around and I couldn't find much on connectivity issues from VM hosts. Especially when I can ssh from the terminal to the oracle server name and port and get a connection.

    Our Oracle database runs on a non-standard port (not 1521) so I don't know if that is tripping up the Oracle Driver.

    I ended up writing a quick program to do a Socket Open and Close in .NET core from the linux VM and was successful in connecting to our Oracle environment, but still failed when I ran the Oracle connection. I was able to successfully connect and close the connection to our DB on our non-standard port.


    using System;

    using System.Net;

    using System.Net.Sockets;

    using Oracle.ManagedDataAccess.Client;

    using System.Collections.Generic;

    namespace consoletest


        class Program


            static void Main(string[] args)


                Console.WriteLine("Hello World!");

                IPHostEntry hostEntry = System.Net.Dns.GetHostEntry("");

                foreach (var ipaddr in hostEntry.AddressList) {

                    Console.WriteLine("hostEntry={0}", ipaddr.ToString());


                // TCP connection to oracle server

                IPAddress ipAddr = hostEntry.AddressList[0];

                IPEndPoint remoteServer = new IPEndPoint(ipAddr, 15xx);

                Socket client = new Socket(ipAddr.AddressFamily, socketType: SocketType.Stream, protocolType: ProtocolType.Tcp);

                try {


                    Console.WriteLine("Successfully connect to oracle on port 15xx");



                    Console.WriteLine("Closed connection to oracle on port 15xx");


                catch {

                    Console.WriteLine("Unable to connect to oracle on port 15xx");


                // Oracle configuration

                OracleConfiguration.TraceFileLocation = @/tmp/oracle-dnc-firstapp-trace.log;

                OracleConfiguration.OracleDataSources.Add("xxxxxxxx", "xxxxxxxxxxx");

                OracleConfiguration.TraceLevel = 7;

                OracleConfiguration.TraceOption = 0;

                OracleConnection cn = null;

                Dictionary<int, string> employees = new Dictionary<int, string>();



                    // Open a connection

                    cn = new OracleConnection("user id=xxxx; password=xxxx; data source=xxxx");


                    // Execute simple select statement that returns first 10 names from TIGER table

                    OracleCommand orclCmd = cn.CreateCommand();

                    orclCmd.CommandText = "select scott from tiger where rownum < 10";

                    OracleDataReader rdr = orclCmd.ExecuteReader();

                    while (rdr.Read())


                        employees.Add(int.Parse(rdr["SCOTT"].ToString()), rdr["SCOTT"].ToString());







                    // Close the connection

                    if (null != cn)






This discussion has been closed.