Files
coder/docs/admin/templates/troubleshooting.md
T
Nick Vigilante c84aa564ba docs: normalize code-fence languages for Shiki compatibility (#27161)
Normalizes non-standard code-fence language tags across `docs/**` so a
strict highlighter (Shiki, used by Fumadocs) won't fail the build on an
unrecognized language, and unifies redundant synonym tags onto one
canonical form per language. The current renderer (Speed-Highlight)
detects the language from the code content, not the fence label, so this
drift wasn't visible until now.

## Changes

- `hcl` -> `tf` (199 fences, including indented ones nested in
numbered/bulleted lists). Shiki ships `hcl` and `terraform` as two
distinct grammars (not aliases); every `hcl`-tagged fence in `docs/**`
is actually Terraform resource/data/provider syntax, so the more
specific `terraform` grammar is correct for all of them. `tf` is Shiki's
own alias for that grammar, and it's also what GitHub's own markdown
renderer resolves to the same HCL/Terraform highlighting.
- `pwsh`/`powershell` -> `ps1`. Both `ps` and `ps1` are registered
PowerShell aliases in Shiki, but on GitHub's renderer only `.ps1` is a
registered file extension (`.ps` isn't), so `ps1` renders identically to
`powershell` there today while bare `ps` would silently lose
highlighting.
- `env` -> `dotenv` (a dedicated Shiki grammar for `KEY=VALUE` files)
- `text`/`output`/`none`/`url` -> `txt`. Same built-in plain-text
fallback either way, just shorter.
- `Dockerfile` -> `dockerfile` (lowercase)
- `bash`/`shell` -> `sh` (732 fences). Shiki and GitHub both alias all
three to a single shell grammar; this was already the style guide's
stated preference, just not enforced across the existing corpus until
now.
- `markdown` -> `md` (4 fences). Alias of the same grammar in both Shiki
and GitHub.
- `jsonc` -> `json` (1 fence). The block has no comments or trailing
commas, so it doesn't need the comments-capable grammar.
- `ts` -> `tsx` (2 fences, `docs/about/contributing/frontend.md`).
Verified the actual content tokenizes identically under both grammars,
and a sibling block in the same file already needs `tsx` for real JSX,
so unifying to one tag is safe for this file. Documented a caveat: `tsx`
mis-tokenizes the legacy angle-bracket type-assertion syntax
(`<Type>value`), which is invalid in real `.tsx` files anyway, so use
`value as Type` instead.
- `yml` -> `yaml` (1 fence)
- Updated `docs/.style/style-guide/formatting.md` to document all
canonical tags

`promql` (2 fences) and `caddyfile` (2 fences) are left as-is. Shiki
doesn't bundle a grammar for either, so they need a custom grammar
registration when the site adopts Shiki, rather than degrading to `txt`.
Tracked as follow-up work under DOCS-118 and
[DOCS-544](https://linear.app/codercom/issue/DOCS-544/vendor-a-local-promql-grammar-for-shiki-syntax-highlighting)
(promql).

Does not touch `offlinedocs/`.

Linear:
[DOCS-476](https://linear.app/codercom/issue/DOCS-476/normalize-docs-code-fence-languages-de-risk-shikifumadocs)

<details>
<summary>How the fence tags were verified</summary>

Each tag was tested against a real `shiki@latest` highlighter instance
(`codeToHtml`/`codeToTokens`) and cross-checked against GitHub's
`@wooorm/starry-night` grammar sources (the renderer that actually
displays these `.md` files today, in repo browsing and PR diffs), since
that's what determines whether brevity is safe before Shiki adoption:

```text
FAIL  env        -- Language `env` is not included in this bundle.
FAIL  Dockerfile -- Language `Dockerfile` is not included in this bundle.
FAIL  promql     -- Language `promql` is not included in this bundle.
FAIL  caddyfile  -- Language `caddyfile` is not included in this bundle.
FAIL  pwsh       -- Language `pwsh` is not included in this bundle.
FAIL  output     -- Language `output` is not included in this bundle.
```

`hcl` doesn't error in Shiki, since it's a real grammar, but that's
exactly the trap: it was silently rendering every fence with the generic
HCL grammar instead of the Terraform-specific one. Every `hcl`-tagged
fence in `docs/**` was manually checked against `origin/main` and is
genuinely Terraform content.

For `ts`/`tsx`, tokenizing the actual doc content confirmed identical
output under both grammars; a synthetic test with the legacy
angle-bracket cast syntax confirmed `tsx` degrades on that specific
construct, which the style guide now calls out.

The first normalization pass only matched fence tags at column 0
(`^```tag$`), missing tags indented inside numbered/bulleted lists. A
follow-up pass caught the remaining occurrences at any indentation
level.

</details>


---

*This PR description and the underlying changes were prepared with Coder
Agents assistance.*
2026-07-15 14:07:09 -04:00

9.9 KiB

Troubleshooting templates

Occasionally, you may run into scenarios where a workspace is created, but the agent is either not connected or the startup script has failed or timed out.

Agent connection issues

If the agent is not connected, it means the agent or init script has failed on the resource.

$ coder ssh myworkspace
⢄⡱ Waiting for connection from [agent]...

While troubleshooting steps vary by resource, here are some general best practices:

  • Ensure the resource has curl installed (alternatively, wget or busybox)
  • Ensure the resource can curl your Coder access URL
  • Manually connect to the resource and check the agent logs (e.g., kubectl exec, docker exec or AWS console)
    • The Coder agent logs are typically stored in /tmp/coder-agent.log
    • The Coder agent startup script logs are typically stored in /tmp/coder-startup-script.log
    • The Coder agent shutdown script logs are typically stored in /tmp/coder-shutdown-script.log
  • This can also happen if the websockets are not being forwarded correctly when running Coder behind a reverse proxy. Read our reverse-proxy docs

Startup script issues

Depending on the contents of the startup script, and whether or not the startup script behavior is set to blocking or non-blocking, you may notice issues related to the startup script. In this section we will cover common scenarios and how to resolve them.

Unable to access workspace, startup script is still running

If you're trying to access your workspace and are unable to because the startup script is still running, it means the startup script behavior option is set to blocking or you have enabled the --wait=yes option (for e.g. coder ssh or coder config-ssh). In such an event, you can always access the workspace by using the web terminal, or via SSH using the --wait=no option. If the startup script is running longer than it should, or never completing, you can try to debug the startup script to resolve the issue. Alternatively, you can try to force the startup script to exit by terminating processes started by it or terminating the startup script itself (on Linux, ps and kill are useful tools).

For tips on how to write a startup script that doesn't run forever, see the startup_script section. For more ways to override the startup script behavior, see the startup_script_behavior section.

Template authors can also set the startup script behavior option to non-blocking, which will allow users to access the workspace while the startup script is still running. Note that the workspace must be updated after changing this option.

Your workspace may be incomplete

If you see a warning that your workspace may be incomplete, it means you should be aware that programs, files, or settings may be missing from your workspace. This can happen if the startup script is still running or has exited with a non-zero status (see startup script error). No action is necessary, but you may want to start a new shell session after it has completed or check the startup script logs to see if there are any issues.

Session was started before the startup script finished

The web terminal may show this message if it was started before the startup script finished, but the startup script has since finished. This message can safely be dismissed, however, be aware that your preferred shell or dotfiles may not yet be activated for this shell session. You can either start a new session or source your dotfiles manually. Note that starting a new session means that commands running in the terminal will be terminated and you may lose unsaved work.

Examples for activating your preferred shell or sourcing your dotfiles:

  • exec zsh -l
  • source ~/.bashrc

Startup script exited with an error

When the startup script exits with an error, it means the last command run by the script failed. When set -e is used, this means that any failing command will immediately exit the script and the remaining commands will not be executed. This also means that your workspace may be incomplete. If you see this error, you can check the startup script logs to figure out what the issue is.

Common causes for startup script errors:

  • A missing command or file
  • A command that fails due to missing permissions
  • Network issues (e.g., unable to reach a server)

Debugging the startup script

The simplest way to debug the startup script is to open the workspace in the Coder dashboard and click "Show startup log" (if not already visible). This will show all the output from the script. Another option is to view the log file inside the workspace (usually /tmp/coder-startup-script.log). If the logs don't indicate what's going on or going wrong, you can increase verbosity by adding set -x to the top of the startup script (note that this will show all commands run and may output sensitive information). Alternatively, you can add echo statements to show what's going on.

Here's a short example of an informative startup script:

echo "Running startup script..."
echo "Run: long-running-command"
/path/to/long-running-command
status=$?
echo "Done: long-running-command, exit status: ${status}"
if [ $status -ne 0 ]; then
  echo "Startup script failed, exiting..."
  exit $status
fi

Note

We don't use set -x here because we're manually echoing the commands. This protects against sensitive information being shown in the log.

This script tells us what command is being run and what the exit status is. If the exit status is non-zero, it means the command failed and we exit the script. Since we are manually checking the exit status here, we don't need set -e at the top of the script to exit on error.

Note

If you aren't seeing any logs, check that the dir directive points to a valid directory in the file system.

Slow workspace startup times

If your workspaces are taking longer to start than expected, or longer than desired, you can diagnose which steps have the highest impact in the workspace build timings UI (available in v2.17 and beyond). Admins can can programmatically pull startup times for individual workspace builds using our build timings API endpoint.

See our guide on optimizing workspace build times to optimize your templates based on this data.

Workspace build timings UI

Cannot connect to the Docker daemon

If a Docker-based template fails to provision with an error like Cannot connect to the Docker daemon at unix:///var/run/docker.sock, the Coder host cannot reach the Docker socket. Confirm that Docker is installed and running on the host. If you run Docker through rootless Docker, Colima, Podman, or a similar tool, the daemon may expose its socket at a non-default path, so set DOCKER_HOST to point at it. Refer to Cannot connect to the Docker daemon for the full steps.

Docker Workspaces on Raspberry Pi OS

Unable to query ContainerMemory

When you query ContainerMemory and encounter the error:

open /sys/fs/cgroup/memory.max: no such file or directory

This error mostly affects Raspberry Pi OS, but might also affect older Debian-based systems as well.

Add cgroup_memory and cgroup_enable to cmdline.txt:
  1. Confirm the list of existing cgroup controllers doesn't include memory:

    $ cat /sys/fs/cgroup/cgroup.controllers
    cpuset cpu io pids
    
    $ cat /sys/fs/cgroup/cgroup.subtree_control
    cpuset cpu io pids
    
  2. Add cgroup entries to cmdline.txt in /boot/firmware (or /boot/ on older Pi OS releases):

    cgroup_memory=1 cgroup_enable=memory
    

    You can use sed to add it to the file for you:

    sudo sed -i '$s/$/ cgroup_memory=1 cgroup_enable=memory/' /boot/firmware/cmdline.txt
    
  3. Reboot:

    sudo reboot
    
  4. Confirm that the list of cgroup controllers now includes memory:

    $ cat /sys/fs/cgroup/cgroup.controllers
    cpuset cpu io memory pids
    
    $ cat /sys/fs/cgroup/cgroup.subtree_control
    cpuset cpu io memory pids
    

Read more about cgroup controllers in The Linux Kernel documentation.