Repository navigation
Description
Problem Description
Coder agents sometimes fail to connect to the Coder server due to a variety of issues, including network restrictions (e.g., DNS issues, firewalls), missing permissions (e.g., CAP_NET_ADMIN), OS or architecture mismatches, and missing tools for downloading the agent binary. Currently, there’s limited guidance in the UI to help users diagnose and resolve these issues effectively, leading to delays in troubleshooting.
For example, failures in the agent bootstrap script can result in non-connecting agents without a clear indication of the root cause. When checking the workspace logs i.e., docker logs <container name or container id> a typical DNS failure log might look like this:
+ trap waitonexit EXIT
+ mktemp -d -t coder.XXXXXX
+ BINARY_DIR=/tmp/coder.1uZgEp
+ BINARY_NAME=coder
+ BINARY_URL=https://coder.example.com:3000/bin/coder-linux-amd64
+ cd /tmp/coder.1uZgEp
+ :
+ status=
+ command -v curl
+ curl -fsSL --compressed http://coder.example.com:3000/bin/coder-linux-amd64 -o coder
curl: (6) Could not resolve host: coder.example.com
+ status=6
+ echo error: failed to download coder agent
+ echo command returned: 6
+ echo Trying again in 30 seconds...
+ sleep 30
error: failed to download coder agent
command returned: 6
Trying again in 30 seconds..Desired Solution
Implement enhanced diagnostics and UI hints that provide actionable guidance to users based on the detected issue. By giving users specific suggestions directly in the UI, they can resolve connectivity issues faster and with less frustration. This includes:
-
Enhanced Error Logging and Diagnostics
- Log detailed error messages for each failure point, covering:
- Network/DNS issues, with suggestions to verify DNS configuration or consult network administrators.
- Download tool availability (e.g.,
curlorwget), with instructions on how to install the required tool. - OS/architecture mismatches with a link to supported environments in the documentation.
- Log detailed error messages for each failure point, covering:
-
UI Hints for Diagnosed Issues1
- Network/DNS Issue: If a DNS or network error is detected, show a UI message like:
“It appears there’s a DNS or firewall issue preventing the agent from connecting to the server. Learn more about network configuration.” - Download Tool Missing: If the required download tools (
curl,wget) are unavailable, suggest a hint:
“Required download tool not found. Please install eithercurlorwget.” - Unsupported OS/Architecture: If OS or architecture compatibility issues arise, prompt users to check supported platforms:
“This environment may be unsupported. Review supported OS and architectures.” - Download Logs: If the agent doesn't connect, link to docs to show how to fetch agent logs outside of Coder.
- Network/DNS Issue: If a DNS or network error is detected, show a UI message like:
Proposed Implementation
- Backend Logging: Improve diagnostic logging in the agent bootstrap script to provide clearer insights into why each specific failure occurs.
- UI Updates1: Implement conditional pop-ups or error messages in the Coder UI that guide users based on diagnosed connectivity issues.
- Documentation Update: Expand documentation with a troubleshooting section that covers all major connectivity blockers, including example configurations.

Activity
[-]Imrpove error[/-][+]Improve agent connection troubleshooting[/+]ethanndickson commentedon Nov 7, 2024
Related to #6711.
I spent a little time on that issue not long ago and we decided it wouldn't be unreasonable for the agent script to attempt to log errors to
/api/v2/workspaceagents/me/logs*, if it was unable to start the agent. This would let issues like a weird environment (no curl, wget) or an unsupported OS/arch get displayed on the Web UI. This is kinda tricky since (afaik) the script can start before the agent token gets inserted into the DB, so it needs to do this on a retry.If there's a network or DNS issue, I don't think we're gonna able to propagate that to the UI in any way. If the script can't download the agent binary, it's not going to be able to post logs to the agent route.
In any case, I think we should definitely improve the log output to make some of these common cases easily identifiable and fixable.
*We'd also need to un-deprecate the route, as there's no way we can do a dRPC call from a bash script.
bpmct commentedon Nov 7, 2024
Nice. It seems like a combination of logs sent to the server, improved logging of the provisioner script, and better documentation is the key here.
Yep, ideally, we can have better hints in the logs of our agent download & install script or even hint that there is a DNS error 🤞🏼
I think it'd be awesome to drill down a bit more on the current gaps in the docs and UI.
matifali commentedon Nov 12, 2024
@EdwardAngert, if you can help find the shortcoming in our getting-started docs.
bpmct commentedon Nov 18, 2024
From #15462:
bpmct commentedon Nov 18, 2024
@johnstcn @SasSwart - related to the envbuilder
git clone failedthing that happened today 😉johnstcn commentedon Nov 25, 2024
We discussed this today in stand-up. There are a few different sorts of issues here:
With regard to 1), we don't have many options for surfacing errors here.
For 2) and 3), a simple API endpoint to send logs back to Coderd that can also be accessible via cURL could provide some way of exposing this information more easily.
bpmct commentedon Nov 25, 2024
Did we also discuss how we can improve the docs and UX to point people to docs, or is this already sufficient?
johnstcn commentedon Nov 25, 2024
No, we were mostly focused on how to improve the troubleshooting situation. We didn't focus much on docs.
coder_scripton the workspace page #15614