This error block is logged when trying to connect to a database from the Oracle Database Client on a Windows server, though the ORA-21561 error may occur on a Linux host as well.

Oracle.DataAccess.Client.OracleException ORA-21561: OID generation failed    at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable)

This most often indicates a local DNS error due to the hosts file.

To resolve, edit the hosts file to include the fully qualified and short names for localhost and the server’s own hostname. So on the client computer running the Oracle Database Client, where the error above is logged, navigate to C:\Windows\System32\drivers\etc and edit the hosts file. Add two uncommented (no #) lines, using the standard localhost IP address, your own domain name, and the client server’s own IP, hostname, domain name. localhost.domain.internal localhost hostname.domain.internal hostname

It should look like this:

It may seem odd to define the client server’s own hostname in hosts and not the database, but this is appropriate.

Confused by running nslookup localhost on the client machine? That will not return results from the hosts file. To test hosts file name resolution from hosts, use powershell, and run Resolve-DnsName localhost.

You do not need to reboot the server or restart any services once the hosts file has been edited. The ORA-21561 error should no longer appear in the logs.

By Atomosk

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Cookie Plugin by Real Cookie Banner