How to fix ORA-12547 TNS lost contact when try to connect to Oracle

November 23, 2012 by 25 Comments 

Issue / Oracle error

sqlplus scott/tiger
SQL*Plus: Release 10.2.0.5.0 - Production on Wed May 18 09:32:35 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
ERROR:
ORA-12547: TNS :lost contact when try to connect to Oracle.

Issue description

I saw that TNS connection issue along with ORA-12547 Oracle error several times, usually when trying to connect to Oracle database server on Unix / Linux host with an OS user that does not belong to oinstall group (Oracle binaries owner group).  In this case, interesting enough that local TNS connection to database (when using tnsnames alias) works fine:

sqlplus scott/tiger@orcl

and only local BEQ protocol connection through an Oracle error ORA-12547:

sqlplus scott/tiger
ERROR:
ORA-12547: TNS:lost contact

There can be different reasons of this issue, but usually the problem is in wrong privileges/ownership of some Oracle binaries located in $ORACLE_HOME/bin directory. Perhaps, Oracle database binaries were installed / linked not correctly or something or somebody has changed the files’ ownership.

Solution

    1. Ensure the DB is up and running and you can connect locally AS SYSDBA to the database using Oracle binaries owner (usually oracle:oinstall Unix / Linux user). If it does not work, probably you encounter a different problem.
    2. Check privileges of an Oracle file on Unix / Linux host where database is running:

cd $ORACLE_HOME/bin
ls -ltr oracle
-rwxr-xr-x    1 oracle   oinstall       136803483 Mar 16 20:32 oracle

    1. Change permissions as below:

chmod 6751 oracle
ls -ltr oracle
-rwsr-s--x    1 oracle   oinstall       136803483 Mar 16 20:32 oracle

    1. Usually the above operation should fix the issue but I suggest continue investigating privileges of other files to avoid further possible problems.  As the matter of fact these special rights of Oracle binaries are set by $ORACLE_HOME/root.sh script on Unix / Linux after the Oracle installation. You can run the script again as root user, if you see more files have wrong permissions or ownership (make backup before, just in case). For that I provide as an example 2 lists of oracle binary files in $ORACLE_HOME/bin directory with correct rights below.

Oracle 11gR2 (11.2.0.3) on Linux Redhat 6.x

-rwsr-s--x.  1 oramcelt oinstall 221227204 Aug 14 12:12 oracle
-rwsr-s--x.  1 oramcelt oinstall 221189362 Aug 14 11:03 oracleO
-rwsr-x---.  1 root     oinstall     71758 Sep 17  2011 oradism
-rws--x---.  1 root     oinstall     44437 Aug 14 11:02 nmo
-rws--x---.  1 root     oinstall     66324 Aug 14 11:02 nmhs
-rws--x---.  1 root     oinstall     34166 Aug 14 11:03 nmb
-rwsr-x---.  1 root     oinstall     43402 Aug 14 11:03 jssu
-rwsr-x---.  1 root     oinstall     43402 Aug 14 11:03 jssu
-rwsr-x---.  1 root     oinstall   1249349 Aug 14 11:03 extjob
-rwsr-s--x.  1 oramcelt oinstall     65799 Aug 14 11:02 emtgtctl2

Oracle 11gR2 (10.2.0.3) on Linux Redhat 4.x

-rwsr-x---  1 root   oinstall    64850 Nov  6  2007 extjob
-rwsr-s---  1 root   oinstall    18376 Mar  1  2006 nmb
-rwsr-s---  1 root   oinstall    19566 Mar  1  2006 nmo
-rwsr-s--x  1 oracle oinstall 95118102 Nov  6  2007 oracle
-r-sr-s---  1 root   oinstall    14456 Nov 15  2006 oradism

Good luck and feel free to add solutions of the same issue in your comments.

Enjoyed this article? Please share it with others using the social site of your choice:

Comments

25 Responses to “How to fix ORA-12547 TNS lost contact when try to connect to Oracle”
  1. Mor says:

    Thanks!
    I did not find the answer on OTN forums – but chmod 6751 oracle did the trick.
    thanks for sharing…

  2. Ted Urban says:

    This issue appears to have started wen an OS patch has been applied. I have found that performing a relink wil also resolve this issue.

  3. anthony says:

    chmod 6751 oracle worked for me as well, thanks.

  4. Luc says:

    Metalink recommends to shutdown the database prior to mess with it, otherwise it could crash the db.

  5. Kirill Loifman says:

    Hi Luc,
    Not a bad idea. Thanks for your remark
    — Kirill

  6. Zelcrin says:

    In my case I re run the root.sh and the error disappear

  7. Harald says:

    In my case, after I rerun root.sh, I have to chmod 6751 oracle, then it works fine.

    RHEL6.4 Oracle 11.2.0.3.0
    After I changed the owner and group id’s, I ran into the problem.

  8. Anna says:

    In our case, we sold the problem by getting permissions to oracle on /dev/null

  9. Kamil Piórek says:

    In our case there was no

    /proc filessystem

    mounted ……

    3hours of seraching ….

  10. Cesario says:

    I had relinked couple of times but it did not fix the issue. The problems was that the file config.o, which had 0 bytes. In order to fix I renamed it to config.o.bad, so Oracle has fixed it creating a good one at the next relink and I was able to acess sqlplus. Here is the steps I used :

    cd $ORACLE_HOME/rdbms/lib
    mv config.o config.o.bad
    cd $ORACLE_HOME
    umask 022
    relinktime=`date ‘+%Y-%m-%d-%H-%M-%S’`
    touch relink_$relinktime.log
    relink all 1>>relink_$relinktime.log 2>>relink_$relinktime.log
    cat relink_$relinktime.log | grep -i FATAL
    cd $ORACLE_HOME/sqlplus/lib
    make -f ins_sqlplus.mk install 1>>relink_$relinktime.log 2>>relink_$relinktime.log

    Of course I had ORACLE_BASE, ORACLE_HOME, LD_LIBRARY_PATH, PATH properly set.

  11. nader says:

    chmod 6751 oracle worked for me as well, thanks.

  12. alireza says:

    tanks for chmod work and save me .

  13. Wilbur says:

    Thank you. This worked for me

  14. Andrew McPherson says:

    Had this issue on a 12.1.0.2 upgrade and couldn’t fix by the usual means. Support had us all over the place, relinking, traces, truss, … Problem was really simple, Unix Admin had mounted the binaries file system with nosuid, which over-rides the suid on the oracle binary!

  15. Yalcin YAVAS says:

    Excellent solution. Thank you.

  16. Sameer Saxena says:

    I got into same error but the issue was caused by incorrect entry in /etc/fstab for oracle binaries related filesystem .
    changing it to suid from nosuid resolved the issue for us .

  17. Hi,

    I encountered the same error while upgrading Oracle 11.2.0.1 to Oracle 11.2.0.3.
    The reason of error was not setting of LD_LIBRARY_PATH.
    The minutes i set it correctly i could connect and do my upgrade.

    Thanks & Rgds.
    M.H.Contractor.

  18. Mahipal says:

    chmod is a brilliant sol. It saved my time. Thanks.

  19. Jacob says:

    chmod 6751 oracle worked for me as well, thanks.

  20. This fixed the error for me as well…
    Thank you.

    SLES 11 with Oracle12

  21. Ovais says:

    not work for me My previous setting was -rwxr-x—, how to revert back this settings ? please anser

  22. Kirill Loifman says:

    Hi Ovais
    just run $ORACLE_HOME/root.sh to set the proper rights and it will most porbably fix your problem.
    — Kirill

  23. sushanth says:

    Excellent, works like a charm…

  24. Juan Vazquez says:

    Another possible solution to ORA-12547 TNS LOST CONTACT for HP-UX for this error:
    Check the /dev/null file. It must be like the following:

    crw-rw-rw- 1 bin bin 3 0x000002 Jan 30 09:05 null
    instead of:
    ———- 1 bin bin 3 0x000002 Jan 30 09:05 null

    If not, fix it. Contacting your hp-ux administrator.

    Regards.

  25. mamatha says:

    chmod 6751 oracle worked for me as well, thanks.

Add a Comment

We welcome thoughtful and constructive comments from readers.
If you want your own picture to show with your comment?
Go get a Globally Recognized Avatar!

DBMS Blog Updates : Subscribe RSS RSS: Subscribe to Articles · Subscribe to Comments Subscribe RSS Receive site updates via email