registration fails silently with long machine hostname #452

Closed
opened 2025-12-29 01:29:33 +01:00 by adam · 4 comments
Owner

Originally created by @nnsee on GitHub (Mar 28, 2023).

Bug description

When the machine hostname is really long, the initial tailscale up hangs with no output.

tailscaled logs show that the POST request gets a response with an empty body:

http2: Transport encoding header ":authority" = "headscale-server"
http2: Transport encoding header ":method" = "POST"
http2: Transport encoding header ":path" = "/machine/register"
http2: Transport encoding header ":scheme" = "https"
http2: Transport encoding header "content-length" = "1118"
http2: Transport encoding header "accept-encoding" = "gzip"
http2: Transport encoding header "user-agent" = "Go-http-client/2.0"
http2: Framer 0xc001fa0380: wrote HEADERS flags=END_HEADERS stream=27 len=7
http2: Framer 0xc001fa0380: wrote DATA flags=END_STREAM stream=27 len=1118 data="{\"Version\":58,\"NodeKey\":\"nodekey:xxx\",\"OldNodeKey\":\"nodekey:0000000000000000000000000000000000000000000000000000000000000000\",\"NLKey\":\"nlpub:xxx" (862 bytes omitted)
http2: Framer 0xc001fa0380: read HEADERS flags=END_STREAM|END_HEADERS stream=27 len=26
http2: decoded hpack field header field ":status" = "200"
http2: decoded hpack field header field "content-length" = "0"
http2: decoded hpack field header field "date" = "Tue, 28 Mar 2023 06:32:21 GMT"
http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=27 len=26

To Reproduce

On Linux, set the hostname to something really long:

sudo hostnamectl hostname AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Try to register that machine:

tailscale up --login-server https://headscale-server

Observe as nothing happens and tailscaled logs fill with unexpected end of JSON input messages.

Headscale logs report the following:

New machine not yet in the database follow_up= machine=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA machine_key=[lPI8p] node_key=[Zdcxg] node_key_old= noise=true

Context info

Tailscale version:

1.38.2-dev20230322
  tailscale commit: 3db61d07ca81aea7b86591d1874e48db01b6abcf-dirty
  go version: go1.20.2

Headscale version:

v0.21.0

Kernel:

Linux ripley 6.2.8-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 22 Mar 2023 22:52:38 +0000 x86_64 GNU/Linux
Originally created by @nnsee on GitHub (Mar 28, 2023). <!-- Headscale is a multinational community across the globe. Our common language is English. Please consider raising the bug report in this language. --> **Bug description** When the machine hostname is really long, the initial `tailscale up` hangs with no output. `tailscaled` logs show that the POST request gets a response with an empty body: ``` http2: Transport encoding header ":authority" = "headscale-server" http2: Transport encoding header ":method" = "POST" http2: Transport encoding header ":path" = "/machine/register" http2: Transport encoding header ":scheme" = "https" http2: Transport encoding header "content-length" = "1118" http2: Transport encoding header "accept-encoding" = "gzip" http2: Transport encoding header "user-agent" = "Go-http-client/2.0" http2: Framer 0xc001fa0380: wrote HEADERS flags=END_HEADERS stream=27 len=7 http2: Framer 0xc001fa0380: wrote DATA flags=END_STREAM stream=27 len=1118 data="{\"Version\":58,\"NodeKey\":\"nodekey:xxx\",\"OldNodeKey\":\"nodekey:0000000000000000000000000000000000000000000000000000000000000000\",\"NLKey\":\"nlpub:xxx" (862 bytes omitted) http2: Framer 0xc001fa0380: read HEADERS flags=END_STREAM|END_HEADERS stream=27 len=26 http2: decoded hpack field header field ":status" = "200" http2: decoded hpack field header field "content-length" = "0" http2: decoded hpack field header field "date" = "Tue, 28 Mar 2023 06:32:21 GMT" http2: Transport received HEADERS flags=END_STREAM|END_HEADERS stream=27 len=26 ``` **To Reproduce** On Linux, set the hostname to something really long: ``` sudo hostnamectl hostname AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ``` Try to register that machine: ``` tailscale up --login-server https://headscale-server ``` Observe as nothing happens and `tailscaled` logs fill with `unexpected end of JSON input` messages. Headscale logs report the following: ``` New machine not yet in the database follow_up= machine=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA machine_key=[lPI8p] node_key=[Zdcxg] node_key_old= noise=true ``` **Context info** Tailscale version: ``` 1.38.2-dev20230322 tailscale commit: 3db61d07ca81aea7b86591d1874e48db01b6abcf-dirty go version: go1.20.2 ``` Headscale version: ``` v0.21.0 ``` Kernel: ``` Linux ripley 6.2.8-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 22 Mar 2023 22:52:38 +0000 x86_64 GNU/Linux ```
adam added the stalebug labels 2025-12-29 01:29:33 +01:00
adam closed this issue 2025-12-29 01:29:33 +01:00
Author
Owner

@kev-the-dev commented on GitHub (May 5, 2023):

Reading through some code, it looks like the max hostname length is 255 characters and was added in #350, It may be that this error is not being piped back to tailscale for some reason.. and it should probably be logged as well. f9c4d577e2/machine.go (L638)

@kev-the-dev commented on GitHub (May 5, 2023): Reading through some code, it looks like the max hostname length is 255 characters and was added in #350, It may be that this error is not being piped back to tailscale for some reason.. and it should probably be logged as well. https://github.com/juanfont/headscale/blame/f9c4d577e2500c77440fd5c7cce8213a14a37e57/machine.go#L638
Author
Owner

@nnsee commented on GitHub (May 5, 2023):

Thanks for taking a look!

If I remember correctly, I did some testing and figured out that 63 characters seemed to be the limit (which makes sense - according to the man page for hostname, each part of the hostname must be 1 to 63 characters long). So perhaps this 255-char limit is not to blame.

@nnsee commented on GitHub (May 5, 2023): Thanks for taking a look! If I remember correctly, I did some testing and figured out that 63 characters seemed to be the limit (which makes sense - according to the [man page for hostname](https://man7.org/linux/man-pages/man7/hostname.7.html), each _part_ of the hostname must be 1 to 63 characters long). So perhaps this 255-char limit is not to blame.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2023):

This issue is stale because it has been open for 180 days with no activity.

@github-actions[bot] commented on GitHub (Nov 2, 2023): This issue is stale because it has been open for 180 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 16, 2023):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (Nov 16, 2023): This issue was closed because it has been inactive for 14 days since being marked as stale.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#452