# Upgrading Elastic-Agent with source-uri failing

**URL:** <https://discuss.elastic.co/t/upgrading-elastic-agent-with-source-uri-failing/307918>\
**Category:** Elastic Observability\
**Created:** [June 22, 2022, 7:40pm UTC](https://discuss.elastic.co/t/upgrading-elastic-agent-with-source-uri-failing/307918 "2022-06-22T19:40:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyltay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dyltay/32/96741_2.png) [@dyltay](https://discuss.elastic.co/u/dyltay)\
**Post date:** [June 22, 2022, 7:40pm UTC](https://discuss.elastic.co/t/upgrading-elastic-agent-with-source-uri-failing/307918/1 "2022-06-22T19:40:27Z")

</div>

Hello,

I'm attempting to upgrade Elastic-Agent 8.0.0 (tar.gz installed) to 8.2.2 via the command found in the documentation:

```auto
elastic-agent upgrade 8.2.2 --source-uri https://URL/elastic-agent-8.2.2-linux-x86_64.tar.gz

```

This is failing with

```auto
Error: Failed trigger upgrade of daemon: cannot be upgraded; perform upgrading using Fleet

```

I can CURL the tar.gz just fine from the server.

This is an air-gapped environment so I must be able to use a URL here. Is there a more detailed error I'm missing here? I put the agent up to debug logging but saw nothing logged when running the upgrade command.

Thanks!

---

<div class="post-metadata">

**Author:** ![marrc.rousseau](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@marrc.rousseau](https://discuss.elastic.co/u/marrc.rousseau)\
**Post date:** [June 29, 2022, 6:41am UTC](https://discuss.elastic.co/t/upgrading-elastic-agent-with-source-uri-failing/307918/2 "2022-06-29T06:41:33Z")

</div>

Same issue with windows agents in air-gapped environment

```auto
PS C:\Program Files\Elastic\Agent> .\elastic-agent.exe upgrade --help
Upgrade the currently running Elastic Agent to the specified version

Usage:
  elastic-agent upgrade <version> [flags]

Flags:
  -h, --help help for upgrade
  -s, --source-uri string Source URI to download the new version from

PS C:\Program Files\Elastic\Agent> .\elastic-agent.exe upgrade 8.1.2 -s "https://xxxxxxxxxxxxxx/pub/ELASTIC/elastic-agent-8.1.2-windows-x86_64.zip"
The upgrade process of Elastic Agent is currently EXPERIMENTAL and should not be used in production
Error: Failed trigger upgrade of daemon: cannot be upgraded; perform upgrading using Fleet
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.1/fleet-troubleshooting.html

```

For linux agents, I finaly choose to use RPM instead of tar.gz. Update is easier.

For windows, only solution I found is to use fleet API to upgrade agents. But setting a source\_uri to bulk\_upgrade API has been disabled :

> <https://github.com/elastic/kibana/pull/123464>
>
> \## Summary
> 
> Today we allow setting a \`source\_uri\` field on the \`/api/fleet/age…nts/:id/upgrade\` and \`/api/fleet/agents/bulk\_upgrade\` APIs which will tell Agents to download their upgrade from an alternative location other than artificats.elastic.co
> 
> Disable this non-GA feature by default for now until better controls can be put in place. See thread starting around https://github.com/elastic/kibana/issues/100413#issuecomment-965643022 for more context.
> 
> This can be re-enabled for testing purposes by setting \`xpack.fleet.developer.allowAgentUpgradeSourceUri\` in \`kibana.yml\`

You have to reenable this setting in kibana.yml:

```auto
xpack.fleet.developer.allowAgentUpgradeSourceUri: true

```

Fleet API is available here:

[https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/fleet/common/openapi/bundled.json#/default/bulk-upgrade-agents](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/fleet/common/openapi/bundled.json#/default/bulk-upgrade-agents)

You can upgrade agents (one by one) this way :

```auto
AGENT=my_agent_name_respect_case
NEWVERSION=8.1.0
AGENTURL="https://xxxxxxx/pub/"

#getid of agent to upgrade
AGENTID=`curl -s -u elastic:xxxx https://xxxxxx:5601/api/fleet/agents?perPage=100 | jq -r ".items[] | select (.local_metadata.host.name == \"$AGENT\") | .id "`

#start agetn upgrade by ID
curl -u elastic:xxxx -X POST "https://xxxxx:5601/api/fleet/agents/bulk_upgrade" -H 'Content-Type: application/json' -H 'kbn-xsrf: true' -d"
{
  \"version\": \"$NEWVERSION\",
  \"source_uri\": \"$AGENTURL\",
  \"agents\": [
    \"$AGENTID\"
  ]
}
"

```

If your URL is [https://xxx/pub/](https://xxx/pub/), on your internal webserver you have to create a specific path and store elastic agents (tar.gz,zip files and also cheksum files : asc,sha512 ) inside

```auto
/var/www/html/pub/beats/elastic-agent/

```

I guess this method works also for linux agents (tar.gz)

Hope it helps

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 8:35am UTC](https://discuss.elastic.co/t/upgrading-elastic-agent-with-source-uri-failing/307918/3 "2022-11-04T08:35:57Z")

</div>


