Can't register a machine via HTTP API (if logged out?), only via gRPC/CLI #356

Closed
opened 2025-12-29 01:27:35 +01:00 by adam · 5 comments
Owner

Originally created by @joshuataylor on GitHub (Oct 23, 2022).

When using the HTTP API, you can't register a machine, I think it's because I'm logged out. This issue has appeared in the past : https://github.com/juanfont/headscale/issues/749 https://github.com/juanfont/headscale/pull/754

The error is "Cannot register machine: machine not found in registration cache".

gRPC & the CLI seems to work fine.

To Reproduce

  1. Login to a namespace
  2. Logout
  3. Try and connect using the HTTP API

curl:

curl -X 'POST' \
  'https://example.com/api/v1/machine/register?namespace=mynamespace&key=xxx' \
  -H "Authorization: Bearer xxx" \
  -H 'accept: application/json' \
  -d ''

The logs for GRPC shows this, when I do tailscale up:

2022-10-23T09:32:50Z INF ../home/runner/work/headscale/headscale/api.go:255 > New machine not yet in the database follow_up= machine=josh node_key=[V1hiq] node_key_old=
2022-10-23T09:33:17Z INF unary dur=6.640852 md={":authority":"192.168.68.110:50443","authorization":"Bearer xxx","content-length":"77","content-type":"application/grpc","user-agent":"grpc-elixir/0.5.0"} method=RegisterMachine req={"key":"xxxx","namespace":"foox"} service=headscale.v1.HeadscaleService
2022-10-23T09:33:20Z INF Client is ready to access the tailnet handler=PollNetMap machine=josh

If using HTTP:

2022-10-23T09:34:55Z ERR unary error="machine not found in registration cache" code=Unknown details=[] dur=0.008619 md={":authority":"/var/run/headscale.sock","authorization":"Bearer xxxx","content-type":"application/grpc","grpcgateway-accept":"application/json,application/json","grpcgateway-authorization":"Bearer xxxx","grpcgateway-content-type":"application/json,application/json","grpcgateway-user-agent":"HeadWeb/0.1,req/0.3.1","user-agent":"grpc-go/1.48.0","x-forwarded-for":"192.168.68.108","x-forwarded-host":"example.com"} method=RegisterMachine msg="machine not found in registration cache" req={} service=headscale.v1.HeadscaleService
Originally created by @joshuataylor on GitHub (Oct 23, 2022). <!-- Headscale is a multinational community across the globe. Our common language is English. Please consider raising the bug report in this language. --> When using the HTTP API, you can't register a machine, I think it's because I'm logged out. This issue has appeared in the past : https://github.com/juanfont/headscale/issues/749 https://github.com/juanfont/headscale/pull/754 The error is "Cannot register machine: machine not found in registration cache". gRPC & the CLI seems to work fine. **To Reproduce** 1. Login to a namespace 2. Logout 3. Try and connect using the HTTP API curl: ```bash curl -X 'POST' \ 'https://example.com/api/v1/machine/register?namespace=mynamespace&key=xxx' \ -H "Authorization: Bearer xxx" \ -H 'accept: application/json' \ -d '' ``` The logs for GRPC shows this, when I do `tailscale up`: ``` 2022-10-23T09:32:50Z INF ../home/runner/work/headscale/headscale/api.go:255 > New machine not yet in the database follow_up= machine=josh node_key=[V1hiq] node_key_old= 2022-10-23T09:33:17Z INF unary dur=6.640852 md={":authority":"192.168.68.110:50443","authorization":"Bearer xxx","content-length":"77","content-type":"application/grpc","user-agent":"grpc-elixir/0.5.0"} method=RegisterMachine req={"key":"xxxx","namespace":"foox"} service=headscale.v1.HeadscaleService 2022-10-23T09:33:20Z INF Client is ready to access the tailnet handler=PollNetMap machine=josh ``` If using HTTP: ``` 2022-10-23T09:34:55Z ERR unary error="machine not found in registration cache" code=Unknown details=[] dur=0.008619 md={":authority":"/var/run/headscale.sock","authorization":"Bearer xxxx","content-type":"application/grpc","grpcgateway-accept":"application/json,application/json","grpcgateway-authorization":"Bearer xxxx","grpcgateway-content-type":"application/json,application/json","grpcgateway-user-agent":"HeadWeb/0.1,req/0.3.1","user-agent":"grpc-go/1.48.0","x-forwarded-for":"192.168.68.108","x-forwarded-host":"example.com"} method=RegisterMachine msg="machine not found in registration cache" req={} service=headscale.v1.HeadscaleService ```
adam added the stalebug labels 2025-12-29 01:27:35 +01:00
adam closed this issue 2025-12-29 01:27:35 +01:00
Author
Owner

@abheekda1 commented on GitHub (Mar 28, 2023):

I'm having the same issue but with the CLI. I'm unable to make sense of what was done in previous issue reports to fix that, but I'm getting the issue like this:

Client:

$ tailscale up --login-server https://headscale.example.tld 

To authenticate, visit:
	https://headscale.example.tld/register/nodekey:xxx

Server:

$ docker-compose exec headscale headscale -u user nodes register --key nodekey:xxx

Cannot register machine: machine not found in registration cache
@abheekda1 commented on GitHub (Mar 28, 2023): I'm having the same issue but with the CLI. I'm unable to make sense of what was done in previous issue reports to fix that, but I'm getting the issue like this: Client: ```bash $ tailscale up --login-server https://headscale.example.tld To authenticate, visit: https://headscale.example.tld/register/nodekey:xxx ``` Server: ``` $ docker-compose exec headscale headscale -u user nodes register --key nodekey:xxx Cannot register machine: machine not found in registration cache ```
Author
Owner

@bmcgonag commented on GitHub (Oct 14, 2023):

Having the same issue on a Windows 11 machine.

Start Tailscale App - Browser opens with the content:

"Machine Registration

Run the command below in the headscale sever to add this machine to your network"

headscale nodes register --user USERNAME --key nodekey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Ran on headscale server, and get the response:

Cannot register machine: machine not found in registration cache

No idea what to try.

@bmcgonag commented on GitHub (Oct 14, 2023): Having the same issue on a Windows 11 machine. Start Tailscale App - Browser opens with the content: "Machine Registration Run the command below in the headscale sever to add this machine to your network" `headscale nodes register --user USERNAME --key nodekey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` Ran on headscale server, and get the response: `Cannot register machine: machine not found in registration cache` No idea what to try.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 12, 2024):

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

@github-actions[bot] commented on GitHub (Jan 12, 2024): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 19, 2024):

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

@github-actions[bot] commented on GitHub (Jan 19, 2024): This issue was closed because it has been inactive for 14 days since being marked as stale.
Author
Owner

@zapotocnylubos commented on GitHub (Mar 27, 2025):

Sorry to bump an older issue, but I was having the same issue now, and I was able to resolve it by reinstalling the tailscale client.

@zapotocnylubos commented on GitHub (Mar 27, 2025): Sorry to bump an older issue, but I was having the same issue now, and I was able to resolve it by reinstalling the tailscale client.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#356