screen -r "There is no screen to be resumed": reattach an Attached or lost session
screen -r says There is no screen to be resumed when the session is still marked Attached or is gone. Use screen -ls, then screen -d -r or -x to get it back.
There is a screen on:
12345.work (11/14/26 17:27:18) (Attached)
There is no screen to be resumed.
screen -r only resumes a detached session. GNU screen detaches by itself when its terminal hangs up. When your connection drops, the old login can stay open on the host until the server notices the connection is gone, so screen has not had the hangup yet and still shows the session as Attached. screen -r then refuses it, even though nobody is using it.
Get the session back
Start with the list:
screen -ls
Then pick by the status shown in brackets:
- (Attached): detach it from the old login and attach it here:
screen -d -r work
-D -r does the same and also logs the old login out. screen -x work attaches without detaching the other side, so the session shows in both places at once (multi-display mode).
- (Detached):
screen -r workworks. With only one detached session,screen -ralone is enough. - (Dead ???): the screen process is gone and only its socket file is left. The programs in it have ended and cannot be brought back.
screen -wiperemoves the leftover socket. - Not in the list: the session has ended. See the causes below.
work is the session name, given with screen -S work when it was started. Without a name, the list shows pid.tty.host; the process number on its own is enough, for example screen -d -r 12345.
Other messages
There is no screen to be resumed matching work.No detached session has that name. It may be attached (use-d -r), dead, or named differently; checkscreen -ls.There are several suitable screens on:More than one session is detached. Name the one you want:screen -r work.No Sockets found in /run/screen/S-user1.No sessions exist for this user on this machine. The folder in the message is where screen looks; it differs between systems.Must be connected to a terminal.screen was started without a terminal, for examplessh host.example.com screen -r. Ask for one withssh -t host.example.com screen -r. See SSH "PTY allocation request failed on channel 0".
Why a session is gone
- The host restarted. Every screen session ends with it.
- Your processes were killed at logout. On systems where systemd ends a login's processes when it logs out, screen goes too, even when detached. See tmux killed on SSH logout: systemd KillUserProcesses and linger; the same applies to screen.
- The program in it exited. When the last window's program ends, screen ends. A session started as
screen -dmS job commandlasts only as long as that command. - You are on a different machine or user. Sessions belong to one user on one host. Behind a load balancer, or after
sudo -i,screen -lsshows a different list.
Detaching when the connection drops is controlled by the autodetach setting, which is on by default. With it off, a hangup ends screen and everything in it.
Start it so that reattaching is easy
screen -D -R work
This attaches to the session named work, detaching it elsewhere first, and creates it if it does not exist. It is a single command for the start of every login. The same idea with tmux is in Keep your work after a disconnect with tmux, and attach automatically.
Related
- Shell and tmux basics
- Keep your work after a disconnect with tmux, and attach automatically
- tmux killed on SSH logout: systemd KillUserProcesses and linger
- Check if a shell is running over SSH, inside tmux, or inside screen
- SSH "client_loop: send disconnect: Broken pipe"