# Bk-agent stop fails with auth error

**URL:** <https://forum.buildkite.community/t/bk-agent-stop-fails-with-auth-error/4349>\
**Category:** General\
**Created:** [April 16, 2025, 9:15pm UTC](https://forum.buildkite.community/t/bk-agent-stop-fails-with-auth-error/4349 "2025-04-16T21:15:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffmcc-persona](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jeffmcc-persona](https://forum.buildkite.community/u/jeffmcc-persona)\
**Post date:** [April 16, 2025, 9:15pm UTC](https://forum.buildkite.community/t/bk-agent-stop-fails-with-auth-error/4349/1 "2025-04-16T21:15:42Z")

</div>

Hi there BK folks.

We have been running our buildkite agents for some time now.  
We happen to run them in docker containers, and we have implemented scale up/down.  
We are running very recent BK agent 3.95.1

I’m trying to improve the behavior of our agent fleet on scale down.  
The agent stop command [docs](https://buildkite.com/docs/agent/v3/cli-stop) seems like just what we want.

We are transitioning from unclustered to clustered agents. In this particular case, the behavior I’m seeing is in our unclustered agent pool. It might we be happening as well in our clustered agent pool; not sure.

Using the same configuration that started buildkite-agent, I get a 401 Auth error, eg:

```plaintext
$ sudo buildkite-agent stop --agent-access-token REDACTED
  ...
buildkite-agent: fatal: failed to stop agent: POST https://agent.buildkite.com/v3/stop: 401 Unauthorized: Invalid access token

```

this happens whether I pass the token on the command line or read it from the config file (as bk-agent start does).

I’ve tried passing `--debug` and `--debug-http`, which don’t seem to provide much of a hint here.

We would prefer to take advantage of the `stop` semantics of gracefully shutting down, but so far have not been successful. Any pointers appreciated.

---

<div class="post-metadata">

**Author:** ![Priya](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Priya](https://forum.buildkite.community/u/Priya)\
**Post date:** [April 17, 2025, 12:53am UTC](https://forum.buildkite.community/t/bk-agent-stop-fails-with-auth-error/4349/2 "2025-04-17T00:53:25Z")

</div>

Hey @jeffmcc-persona 👋

Welcome to the Buildkite community!

Would you able to send the build link to [support@buildkite.com](mailto:support@buildkite.com) so we can continue further investigation?

Cheers,  
Priya
