# fly\_app\_release\_command overrides primary\_region based on your IP

**URL:** <https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302>\
**Category:** General\
**Tags:** databases, login-only\
**Created:** [July 6, 2025, 2:42am UTC](https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302 "2025-07-06T02:42:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmark](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mmark/32/47503_2.png) [@mmark](https://community.fly.io/u/mmark)\
**Post date:** [July 6, 2025, 2:42am UTC](https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302/1 "2025-07-06T02:42:54Z")

</div>

Hi,

So, finally figured this out. Whenever I would run `fly deploy` or `fly deploy -e PRIMARY_REGION=xxx` (regardless that I set the proper env in my fly.toml) the runner will launch from a region related to my current VPN IP address and not my primary region.

This meant that whenever I had the vpn on, it would deploy to another region that wasn’t my primary region and then fail with my multi-node setup with an Ecto error (running elixir/phoenix) as it tried to run migrations.

As soon as I turned the VPN off, then it stuck to my primary region for the `fly_app_release_command` builder.

Not sure if this is expected behavior, but my thought is that I should be able to override that behavior based on `fly deploy -e PRIMARY_REGION=xxx` or even with my env set in my fly.toml (rather than my vpn’s IP address dictating where the fly\_app\_release\_command launches.

Anyway, thought I’d share in case it helps someone else avoid running around in circles for awhile. 😊✌

Best,  
Mark

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [July 6, 2025, 5:55am UTC](https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302/2 "2025-07-06T05:55:18Z")

</div>

Hm… Maybe try setting it at the very beginning of `fly.toml`, rather than under `[env]`. The behavior that you described does contradict the [current docs](https://fly.io/docs/reference/configuration/#run-one-off-commands-before-releasing-a-deployment) (which perhaps you’ve already seen):

> To ensure the command runs in a specific region, such as `dfw`, set `PRIMARY_REGION = 'dfw'` in your application environment in `fly.toml` or with `fly deploy -e PRIMARY_REGION=dfw`.

However, at least with my ancient version of `flyctl` (v0.1.141), it really only looks at the top-level `primary_region` key in `fly.toml`, and that’s a slightly different thing…

```TOML
app = "abc-so-cat"
primary_region = "lax" # ←

[env]
  FOO = "BAR"
  PRIMARY_REGION = "sea" # this, in contrast, is ignored.

[deploy]
  release_command = "printenv PRIMARY_REGION RELEASE_COMMAND"

[build]
  image = "debian:bookworm-slim"

[processes]
  app = "sleep inf"

```

With `fly deploy` and `fly deploy -e PRIMARY_REGION=sea`, it reliably prints `lax` during the release command, even though I’m all the way over on the opposite coast.

(This makes sense to me, since `[env]` and `-e` both set environment variables _within_ the Machine—whereas region selection is part of orchestration, bluegreen degas dancer, which happens outside.)

---

<div class="post-metadata">

**Author:** ![mmark](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mmark/32/47503_2.png) [@mmark](https://community.fly.io/u/mmark)\
**Post date:** [July 6, 2025, 1:09pm UTC](https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302/4 "2025-07-06T13:09:05Z")

</div>

You are so right, that does make sense, thank you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [July 13, 2025, 1:09pm UTC](https://community.fly.io/t/fly-app-release-command-overrides-primary-region-based-on-your-ip/25302/5 "2025-07-13T13:09:50Z")

</div>

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