# "unexpected error claiming task" when running self-hosted runner

**URL:** <https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180>\
**Category:** Build Environment\
**Tags:** runner\
**Created:** [October 18, 2024, 3:31pm UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180 "2024-10-18T15:31:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![merwan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/merwan/32/35346_2.png) [@merwan](https://discuss.circleci.com/u/merwan)\
**Post date:** [October 18, 2024, 3:31pm UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/1 "2024-10-18T15:31:25Z")

</div>

Hi,  
We have been successfully running a self-hosted runner on our infrastructure for about two years. However, it suddenly stopped working on Thursday 2024-10-17.  
The runner is running as a docker container and we get the following error in the logs every 10 seconds:

```auto
time="2024-10-17T11:47:05Z" level=error msg="error running task" error="unexpected error claiming task: server supplied detail: https://runner.circleci.com/api/v3/runner/claim (301-Moved Permanently)"

```

I can reproduce the issue when running a container from my local machine with a new token.

The docker compose file used to run the container is the following (we use the latest image from CircleCI):

```yaml
---
services:
  runner:
    image: circleci/runner:launch-agent
    restart: unless-stopped
    env_file: circleci.env

```

And the `circle.env` content is:

```bash
CIRCLECI_RESOURCE_CLASS=org_name/resource_name
CIRCLECI_API_TOKEN=the_api_token

```

I opened a support ticket but got no answer for the time being. Can someone please help us here?

---

<div class="post-metadata">

**Author:** ![dwalkes](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dwalkes/32/35737_2.png) [@dwalkes](https://discuss.circleci.com/u/dwalkes)\
**Post date:** [October 19, 2024, 5:43pm UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/2 "2024-10-19T17:43:54Z")

</div>

Same issue for me, autoscale AWS runner based on circleci website `blog/autoscale-self-hosted-runners-aws/` which has been working great for the past ~6 months until this week.

---

<div class="post-metadata">

**Author:** ![merwan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/merwan/32/35346_2.png) [@merwan](https://discuss.circleci.com/u/merwan)\
**Post date:** [October 21, 2024, 7:27am UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/3 "2024-10-21T07:27:34Z")

</div>

Just got a response from CircleCI support to indicate that we are using a deprecated solution. Read the message below.

I will post later on how we replace this deprecated solution.

> After reviewing the logs, it appears that your runner is attempting to access an endpoint that was deprecated on **April 30, 2024**. We have extended the support for this endpoint until the end of August to assist you during this transition period.
> 
> To mitigate this issue and ensure continued seamless operation, we recommend migrating from the launch agent to **Machine Runner 3.0**. Please follow the appropriate migration guide based on your operating system:  
> ​
> 
> - [Migrate from Launch Agent to Machine Runner 3.0 on Linux](https://circleci.com/docs/migrate-from-launch-agent-to-machine-runner-3-on-linux/)
> - [Migrate from Launch Agent to Machine Runner 3.0 on macOS](https://circleci.com/docs/migrate-from-launch-agent-to-machine-runner-3-on-macos/)
> - [Migrate from Launch Agent to Machine Runner 3.0 on Windows](https://circleci.com/docs/migrate-from-launch-agent-to-machine-runner-3-on-windows/)
> 
> We have communicated the deprecation through various channels to keep our users informed:  
> ​
> 
> - ​[Launch Agent 1.x Variants End of Life](https://circleci.com/changelog/launch-agent-1-x-variants-eol/)
> - [Machine Runner 3.0 Now Available](https://discuss.circleci.com/t/machine-runner-3-0-now-available/49306)
> - [Machine Runner 3.0 GA with Support for macOS and Windows](https://discuss.circleci.com/t/machine-runner-3-0-ga-now-w-support-for-macos-and-windows/49812)
> 
> Additionally, we will conduct a brownout from **July 31st, 9 AM PST to August 1st, 9 AM PST** (24 hours) to ensure all users are aware of the upcoming end-of-life.
> 
> [CircleCI Status - Brownout: Deprecation Notice for Runner Launch Agent 1.1 variants](https://status.circleci.com/incidents/7jy5kpsbh8q4)
> 
> We have sent notifications regarding this deprecation on the following dates:
> 
> - March 29, 2024
> - April 25, 2024
> - July 19, 2024
> - July 29, 2024

---

<div class="post-metadata">

**Author:** ![merwan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/merwan/32/35346_2.png) [@merwan](https://discuss.circleci.com/u/merwan)\
**Post date:** [October 21, 2024, 10:33am UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/4 "2024-10-21T10:33:15Z")

</div>

Migration was simple, I followed the instructions from the article [Install machine runner 3.0 on Docker](https://circleci.com/docs/install-machine-runner-3-on-docker/).  
The new `docker-compose.yml` file is:

```yaml
---
services:
  runner:
    image: circleci/runner-agent:machine-3
    restart: unless-stopped
    env_file: circleci.env

```

And the `circleci.env` file:

```bash
CIRCLECI_RUNNER_NAME=any_runner_name
CIRCLECI_RUNNER_API_AUTH_TOKEN=the_api_token

```

After launching the container, it is visible in the " Self-Hosted Runners" page on the CircleCI UI

---

<div class="post-metadata">

**Author:** ![dwalkes](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/dwalkes/32/35737_2.png) [@dwalkes](https://discuss.circleci.com/u/dwalkes)\
**Post date:** [October 21, 2024, 10:28pm UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/5 "2024-10-21T22:28:39Z")

</div>

Thanks,

I’m not able to share links, so you’ll need to build based on prepending with circleci and github below.

In my case it was a bit more complicated, basically the instructions at /blog/autoscale-self-hosted-runners-aws/ assume the no longer supported version of the runner, especially the content at github /sebastian-lerner/nodejs-circleci-runner/blob/main/aws\_config/install\_runner\_ubuntu.sh

I was able to get things going again by sequencing in the changes from circleci docs/install-machine-runner-3-on-linux/ and replacing relevant content from

Key changes from previous:

1. Default workdir has changed from /opt to /var
2. Runner now runs as a dedicated “circleci” account instead of root. This necessitates `"ExecStopPost=+shutdown -h"` in the service file with leading “+” to run shutdown as root.
3. Config files have changed location.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [October 28, 2024, 10:29pm UTC](https://discuss.circleci.com/t/unexpected-error-claiming-task-when-running-self-hosted-runner/52180/6 "2024-10-28T22:29:32Z")

</div>

Closed on October 28, 2024, 10:29pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
