> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wrapper.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Local attach

> Join a live host shell on the same machine over loopback.

Local attach connects a second terminal to the host PTY on `127.0.0.1`. Traffic
never leaves the machine and never uses the Fly relay.

## Before you attach

1. Install the CLI.
2. Run `wrapper share` or `wrapper run -- <cmd>` (does not patch your shell config).
3. Confirm a live session:

```bash theme={null}
wrapper status
```

You should see `sessionId`, `pid`, and `port`.

## Attach

Default picker / latest session:

```bash theme={null}
wrapper attach
```

Target a specific session:

```bash theme={null}
wrapper attach --id <sessionId>
wrapper attach --port <port>
```

Defaults:

| Flag | Default |
| - | - |
| `--host` / `-H` | `127.0.0.1` |

## How local security works

* The host WebSocket listens only on loopback.
* Each session generates a random 256-bit token.
* The token is stored in the owner's session registry under restrictive file
  modes and required as `?token=` on every local connection.
* `wrapper attach` reads that registry, so only your OS user (or root) can join.

Processes running as the same OS account remain inside the local trust boundary.
See [Security and privacy](https://docs.wrapper.sh/configuration/security.md).

## Detach without ending the host

In the viewer, press `Ctrl+\` then `d`. The host shell keeps running until the
inner shell exits.

## Common failures

| Symptom | Likely cause | Fix |
| - | - | - |
| No sessions listed | No host running | Run `wrapper share` |
| Access denied | Missing local token | Use `wrapper attach --id` from `wrapper status` |
| Attach connects then dies | Nested / duplicate wrap | `wrapper uninstall` then use `wrapper share` |
| Need an unwrapped shell | Optional wrap always on | `WRAPPER_DISABLE=1 zsh` |

Debug with:

```bash theme={null}
wrapper logs --follow
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.