in linux

Access to (Attached) screen after connection dropped

Sometimes, when you try to re-attach to screen session you are told that the screen session is still attached. Mostly happen when we are working in a flaky Internet connection.

[email protected]:~# screen -ls
There is a screen on:
20105.pts-3.vagrant    (05/13/2016 12:48:56 PM)    (Attached)
1 Socket in /var/run/screen/S-root.


Here is a simple workaround way to take back that screen session.

screen -D -r '20105.pts-3.vagrant'

Here is a longer way to remove the process that is attached to that screen session, so you can reattach to it and continue with whatever you were doing.

  • Figure out which tty is holding on to the screen session by typing into terminal
    ps -ef | grep screen | grep tty
  • You will get something like this
    user 5730 5688 0 12:31 ttyp1 00:00:00 screen -r 20105.pts-3.vagrant
  • In this case the tty is 5688, use this to find the login bash that is associated with that tty
    ps -ef | grep bash | grep 5688
  • result of this should be something like
    user 5688 5687 0 12:28 ttyp1 00:00:00 -bash
  • kill process
    kill -9 5687

Now you should be free to re-attach to this screen session.