kovidgoyal/kitty · error · SocketClosed
Remote control connection was closed by kitty without any re
Error message
Remote control connection was closed by kitty without any response being received
What it means
The socket was closed by kitty without any DCS-framed response — usually kitty exited or the connection (often an SSH tunnel) dropped mid-request.
Source
Thrown at kitty/remote_control.py:364
else:
for chunk in data:
if isinstance(chunk, str):
chunk = chunk.encode('utf-8')
out.write(chunk)
out.flush()
self.socket.shutdown(socket.SHUT_WR)
def simple_recv(self, timeout: float) -> bytes:
dcs = re.compile(rb'\x1bP@kitty-cmd([^\x1b]+)\x1b\\')
self.socket.settimeout(timeout)
st = monotonic()
with self.socket.makefile('rb') as src:
data = src.read()
m = dcs.search(data)
if m is None:
if monotonic() - st > timeout:
raise TimeoutError('Timed out while waiting to read cmd response')
raise SocketClosed('Remote control connection was closed by kitty without any response being received')
return bytes(m.group(1))
class RCIO(TTYIO):
def simple_recv(self, timeout: float) -> bytes:
ans: list[bytes] = []
read_command_response(self.tty_fd, timeout, ans)
return b''.join(ans)
def do_io(to: str | None, original_cmd: dict[str, Any], no_response: bool, response_timeout: float, encrypter: 'CommandEncrypter') -> dict[str, Any]:
payload = original_cmd.get('payload')
if not isinstance(payload, GeneratorType):
send_data: bytes | Iterator[bytes] = encode_send(encrypter(original_cmd))
else:
def send_generator() -> Iterator[bytes]:
assert payload is not NoneView on GitHub (pinned to 6d5d0c4406)
Solutions
- Check that kitty is still running (pid/socket)
- For SSH transports, verify the SSH connection is alive and retry
- Re-establish the remote control channel and resend the command
Defensive patterns
Strategy: retry
Try / catch
except SocketClosed: re-open transport / re-run kitten command
Prevention
- Keep the SSH session alive during RC calls
- Check kitty's pid/socket existence before long command batches
When it happens
Trigger: The read returns data without a DCS match while still inside the timeout: kitty crashed/exited or the socket was closed. Common with 'kitten @cmd --to ssh:host' when the SSH connection terminates.
Common situations: SSH transport dying, kitty being quit while a remote-control command is in flight, or a KittyNotRunningSibling scenario.
Related errors
- This should be run as kitten icat
- This should be run as `kitten notify ...`
- Remote control not enabled, this kitten should be run via a
- The remote control password was invalid: {data!r}
- Remote control is not enabled, remember to use allow_remote_
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/b31169f8dc502958.
Report an issue: GitHub.