Skip to content

Incompatible with Headscale v0.28 API #12

Closed

Description

@simplify123

Problem

Scale Manager fails to connect to Headscale v0.27+ servers with "invalid api key" error, even when the API key is valid and works correctly in the Headscale Web UI.

Root Cause

Headscale v0.27 changed all API endpoint paths from plural to singular:

Scale Manager requests Headscale v0.27 actual route
GET /api/v1/nodes GET /api/v1/node
GET /api/v1/users GET /api/v1/user
GET /api/v1/apikeys GET /api/v1/apikey
GET /api/v1/preauthkeys GET /api/v1/preauthkey
GET /api/v1/healthz GET /api/v1/health

All plural endpoints return 404 Not Found, causing the app to display "invalid api key".

The correct routes can be verified via the OpenAPI spec at /swagger/v1/openapiv2.json on any running Headscale instance.

Reproduction Steps

  1. Deploy Headscale v0.27.1
  2. Create an API key via headscale apikeys create
  3. Enter server URL and API key in Scale Manager
  4. App shows "invalid api key"

Environment

  • Headscale version: v0.27.1
  • Scale Manager version: 1.2.5
  • Platform: iOS

Suggested Fix

Update the API client to use singular endpoint names matching the v0.27+ API spec. Consider supporting both formats for backward compatibility with older Headscale versions.

Activity

  1. gm852 commented on Jul 1, 2026

    @gm852
    Contributor

    Thank you @simplify123! This issue will be addressed in the next update soon.

  2. self-assigned this
    on Jul 1, 2026
  3. added
    bug
    on Jul 1, 2026
  4. gm852 commented on Jul 5, 2026

    @gm852
    Contributor

    Updated v1.2.6 .apk is now available here. iOS version is under review and should be released within 48 hours.

  5. simplify123 commented on Jul 16, 2026

    @simplify123
    Author
  6. reopened this on Jul 16, 2026
  7. gm852 commented on Aug 16, 2026

    @gm852
    Contributor

    @simplify123 i cannot recreate this issue, and the code is set to call the singular endpoints for Headscale v0.27. If possible, can you share any proxy access logs showing plural hits or the status codes of the singular requests? In addition ensure your app is on the proper version as that could also be a issue.

    (sorry for delay in response, day job and life have been super busy)

  8. simplify123 commented on Aug 17, 2026

    @simplify123
    Author

    scale manager version:1.2.6
    tailscale client version:1.102.2(ios)
    device: iphone 17 pro
    headscale v0.28.0 log:

    2026-08-14T03:13:37Z INF Opening database database=sqlite3 path=/var/lib/headscale/db.sqlite
    2026-08-14T03:13:37Z INF Starting Headscale commit=97fa117c48a58bee3941e5e8b4393873501afe14 version=v0.28.0
    2026-08-14T03:13:37Z INF Clients with a lower minimum version will be rejected minimum_version=v1.74
    2026-08-14T03:13:38Z INF listening and serving HTTP on: 0.0.0.0:8080
    2026-08-14T03:13:38Z INF listening and serving debug and metrics on: 127.0.0.1:9090
    2026-08-14T04:26:43Z INF invalid token client_address=xx.xx.xx.xx:44416
    2026-08-14T04:31:47Z INF invalid token client_address=xx.xx.xx.xx:37322
    2026-08-14T04:31:47Z INF invalid token client_address=xx.xx.xx.xx:37322
    2026-08-14T06:13:38Z INF Fetching DERPMap updates
    2026-08-14T09:13:38Z INF Fetching DERPMap updates
    2026-08-14T12:13:38Z INF Fetching DERPMap updates
    2026-08-14T15:13:38Z INF Fetching DERPMap updates
    2026-08-14T18:13:38Z INF Fetching DERPMap updates
    2026-08-14T21:13:38Z INF Fetching DERPMap updates
    2026-08-15T00:13:38Z INF Fetching DERPMap updates
    2026-08-15T03:13:38Z INF Fetching DERPMap updates
    2026-08-15T06:13:38Z INF Fetching DERPMap updates
    2026-08-15T09:13:38Z INF Fetching DERPMap updates
    2026-08-15T12:13:38Z INF Fetching DERPMap updates
    2026-08-15T15:13:38Z INF Fetching DERPMap updates
    2026-08-15T18:13:38Z INF Fetching DERPMap updates
    2026-08-15T21:13:38Z INF Fetching DERPMap updates
    2026-08-16T00:13:38Z INF Fetching DERPMap updates
    2026-08-16T03:13:38Z INF Fetching DERPMap updates
    2026-08-16T04:52:14Z INF invalid token client_address=xx.xx.xx.xx:37402
    2026-08-16T04:56:15Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:21Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:22Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:24Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:27Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:30Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:33Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:36Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:39Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:42Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:45Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:48Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:51Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:54Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:56:57Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:00Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:03Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:06Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:09Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:13Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:57:15Z INF invalid token client_address=xx.xx.xx.xx:47076
    2026-08-16T04:58:14Z INF invalid token client_address=xx.xx.xx.xx:60032
    2026-08-16T04:58:15Z INF invalid token client_address=xx.xx.xx.xx:60032
    2026-08-16T06:13:38Z INF Fetching DERPMap updates
    2026-08-16T09:13:38Z INF Fetching DERPMap updates
    2026-08-16T12:13:38Z INF Fetching DERPMap updates
    2026-08-16T15:13:38Z INF Fetching DERPMap updates
    2026-08-16T18:13:38Z INF Fetching DERPMap updates
    2026-08-16T21:13:38Z INF Fetching DERPMap updates
    2026-08-17T00:13:38Z INF Fetching DERPMap updates
    2026-08-17T01:53:42Z INF invalid token client_address=xx.xx.xx.xx:35816
    2026-08-17T02:02:09Z INF invalid token client_address=xx.xx.xx.xx:36146
    2026-08-17T02:26:03Z INF home/runner/work/headscale/headscale/hscontrol/app.go:410 > failed to validate token error="failed to parse ApiKey: key too short, expected at least 77 chars after prefix, got 64" client_address=x.x.x.x:7624
    2026-08-17T02:30:39Z INF home/runner/work/headscale/headscale/hscontrol/app.go:410 > failed to validate token error="failed to parse ApiKey: secret length mismatch, expected 64 chars, got 70" client_address=x.x.x.x:7855
    2026-08-17T02:33:53Z INF home/runner/work/headscale/headscale/hscontrol/app.go:410 > failed to validate token error="failed to parse ApiKey: secret length mismatch, expected 64 chars, got 80" client_address=x.x.x.x:8068
    2026-08-17T02:34:14Z INF home/runner/work/headscale/headscale/hscontrol/app.go:410 > failed to validate token error="invalid API key: crypto/bcrypt: hashedPassword is not the hash of the given password" client_address=x.x.x.x:8096
    2026-08-17T02:44:43Z INF invalid token client_address=xx.xx.xx.xx:51112
    2026-08-17T03:13:38Z INF Fetching DERPMap updates
    2026-08-17T03:28:24Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:38131
    2026-08-17T03:28:24Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:14021
    2026-08-17T03:28:25Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:15028
    2026-08-17T03:28:26Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:11100
    2026-08-17T03:28:53Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:26809
    2026-08-17T03:28:53Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:52961
    2026-08-17T03:29:01Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:10073
    2026-08-17T03:29:01Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:49003
    2026-08-17T03:30:23Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:43799
    2026-08-17T03:30:23Z ERR home/runner/work/headscale/headscale/hscontrol/app.go:400 > missing "Bearer " prefix in "Authorization" header client_address=x.x.x.x:62908
    
  9. simplify123 commented on Aug 17, 2026

    @simplify123
    Author

    I'm running Headscale v0.28.0 and ScaleManager can not log in. I think the cause is the API key format change in v0.28.0.

    Since v0.28.0, Headscale stores API keys as bcrypt hashes and expects the new prefixed format hskey-api-{prefix}-{secret} instead of the old plain 64-character secret. The server logs show the app is still sending the old format:

    failed to validate token error="failed to parse ApiKey: key too short, expected at least 77 chars after prefix, got 64"
    failed to validate token error="failed to parse ApiKey: secret length mismatch, expected 64 chars, got 70"
    failed to validate token error="invalid API key: crypto/bcrypt: hashedPassword is not the hash of the given password"
    

    Could you update the app to support the new key format? Headplane already fixed the same issue in v0.6.2, so it should be straightforward.

    Headscale: v0.28.0 (commit 97fa117c48a58bee3941e5e8b4393873501afe14)
    The full server log is in my previous comment.

    The previous API key(headscale v0.27.1) format was: TXp1jpD.CppZBvSvtDzgvHgN7IDrRF_STlNbn2tb
    The current API key(headscale v0.28.0) format is: hskey-api-oOfm0YYCkAP3-PzFqpnpKG6dZbdunXjb21qeUj1ptBpSsYvYOqdgmaT8noeHIfDYAeq7KJyqquHs2

  10. changed the title [-]Incompatible with Headscale v0.27 API (singular endpoint names)[/-] [+]Incompatible with Headscale v0.28 API[/+] on Aug 17, 2026
  11. simplify123 commented on Aug 17, 2026

    @simplify123
    Author

    @simplify123 i cannot recreate this issue, and the code is set to call the singular endpoints for Headscale v0.27. If possible, can you share any proxy access logs showing plural hits or the status codes of the singular requests? In addition ensure your app is on the proper version as that could also be a issue.

    (sorry for delay in response, day job and life have been super busy)

    Root cause 100% confirmed: iOS ATS (App Transport Security) is blocking the plaintext HTTP requests from ScaleManager. Since the app’s release build does not include the NSAllowsArbitraryLoads entry, iOS blocks all http:// connections at the system level—requests never reach the server. Safari has an exemption (it prompts a warning but still allows the connection), which is why the page loads in the browser but the app cannot connect.

  12. gm852 commented on Aug 25, 2026

    @gm852
    Contributor

    okay @simplify123 thanks for the logs, although lets please try to avoid using large amounts of AI generated diagnoses please. This clutters everything up, is not super accurate, and makes my job a bit harder. Lets break this down properly so we can close this out asap and apply any actually needed fixes.

    What’s already in the app (including 1.2.6):

    • API calls use singular Headscale paths (/api/v1/node, /user, /apikey, etc.)
    • There’s a singular/plural fallback on 404
    • Auth is sent as Authorization: Bearer with the key pasted as-is (no reformatting)

    In your logs:

    • invalid token means the request did reach Headscale so this isn’t App Transport Security blocking the connection (ATS would prevent the request from arriving at all)
    • The missing "Bearer " and some of the key-parse errors look like they may be from other clients/manual tests mixed into the same log. Scale Manager always sends the Bearer prefix

    Originally you claimed this issue was happening on Headscale v0.27 but now claiming v0.28. Headscale did change the key formatting in v0.28 so yes this is a issue that will need to be addressed and i am currently working on a fix in addition to support for v0.29. I appreciate the patience while we get this update out, thanks for your issue.

  13. simplify123 commented on Sep 14, 2026

    @simplify123
    Author

    okay @simplify123 thanks for the logs, although lets please try to avoid using large amounts of AI generated diagnoses please. This clutters everything up, is not super accurate, and makes my job a bit harder. Lets break this down properly so we can close this out asap and apply any actually needed fixes.好的,谢谢你提供的日志。不过,请尽量避免使用大量的 AI 生成的诊断结果。这会让系统变得混乱,准确率也不高,而且会增加我的工作难度。我们来仔细分析一下这个问题,以便尽快解决并进行必要的修复。

    What’s already in the app (including 1.2.6):应用内已有的功能(包括 1.2.6 版本):

    • API calls use singular Headscale paths (/api/v1/node, /user, /apikey, etc.)API 调用使用单个 Headscale 路径(/api/v1/node、/user、/apikey 等)。
    • There’s a singular/plural fallback on 404404 错误有单数/复数回退机制
    • Auth is sent as Authorization: Bearer with the key pasted as-is (no reformatting)授权信息以 Authorization: Bearer 的形式发送,密钥原封不动地粘贴进去(不进行任何格式调整)。

    In your logs:  在您的日志中:

    • invalid token means the request did reach Headscale so this isn’t App Transport Security blocking the connection (ATS would prevent the request from arriving at all)无效令牌意味着请求已到达 Headscale,因此这不是应用传输安全机制 (ATS) 阻止连接导致的(ATS 会阻止请求到达)。
    • The missing "Bearer " and some of the key-parse errors look like they may be from other clients/manual tests mixed into the same log. Scale Manager always sends the Bearer prefix缺失的“Bearer”前缀和一些密钥解析错误看起来像是其他客户端/手动测试的日志混杂在一起造成的。Scale Manager 始终会发送 Bearer 前缀。

    Originally you claimed this issue was happening on Headscale v0.27 but now claiming v0.28. Headscale did change the key formatting in v0.28 so yes this is a issue that will need to be addressed and i am currently working on a fix in addition to support for v0.29. I appreciate the patience while we get this update out, thanks for your issue.您最初声称此问题出现在 Headscale v0.27 版本中,但现在又说出现在 v0.28 版本中。Headscale 在 v0.28 版本中确实更改了按键格式,所以这确实是一个需要解决的问题。我目前正在修复此问题,同时也在努力支持 v0.29 版本。感谢您在我们发布此更新期间的耐心等待,也感谢您反馈此问题。

    I manually tested this and confirmed that iOS ATS (App Transport Security) was blocking the plaintext HTTP requests being sent by ScaleManager. When I switched to using Cloudflare's HTTPS address, I was able to log in successfully. However, using HTTP resulted in failure.

  14. gm852 commented on Sep 30, 2026

    @gm852
    Contributor

    This issue has been addressed and fixed as of Scale Manager release 1.2.7. The iOS app is currently being distributed and the APK is on the releases page.

  15. linked a pull request that will close this issueV1.2.7 #13on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions