# 503 using fly-machine-id cookie

**URL:** <https://community.fly.io/t/503-using-fly-machine-id-cookie/21430>\
**Category:** Questions / Help\
**Tags:** proxy, login-only\
**Created:** [August 20, 2024, 12:47pm UTC](https://community.fly.io/t/503-using-fly-machine-id-cookie/21430 "2024-08-20T12:47:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeygennari](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/joeygennari/32/37483_2.png) [@joeygennari](https://community.fly.io/u/joeygennari)\
**Post date:** [August 20, 2024, 12:47pm UTC](https://community.fly.io/t/503-using-fly-machine-id-cookie/21430/1 "2024-08-20T12:47:41Z")

</div>

Following the session affinity doc found [here](https://fly.io/docs/blueprints/sticky-sessions/), I’m setting a response cookie (fly-machine-id) to the value in the request header with an expiration of 6 days. However if I scale out to different regions within those 6 days, and those original [Fly.io](http://Fly.io) machine id’s go down, any requests to my app with the old fly-machine-id will return a 503 error.

My assumption would be if a machine ID is no longer associated with the domain/app, that the load balancer would strip the cookie and return a new machine id. The client would be completely oblivious to change in the machine IDs, so without it, the only way to reach the site is to wait for the cookie expiration, or clear the cookie.

Here’s the behavior:  
https://www.loom.com/embed/cedf8b41887d4ab281b28db7940f84c6?sid=db824b79-4afa-4531-a3a5-4f89974aaff4

---

<div class="post-metadata">

**Author:** ![joeygennari](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/joeygennari/32/37483_2.png) [@joeygennari](https://community.fly.io/u/joeygennari)\
**Post date:** [August 20, 2024, 1:11pm UTC](https://community.fly.io/t/503-using-fly-machine-id-cookie/21430/2 "2024-08-20T13:11:46Z")

</div>

Looks like @khuezy hit this too:

> [@Support for Sticky Session](https://community.fly.io/t/support-for-sticky-session/20835/17):
>
> This works great but there might be an edge case that fly should consider addressing: if a machine that was set on the user’s cookie is destroyed, the request from that user will hang indefinitely. It looks like Fly replay isn’t making sure that the machine exists before replaying the request. After about a minute or so, the request errors w/ 503. I’m guessing the Fly edge should also also expire the cookie, but that cookie key is user defined, so it’s not as straightforward.

---

<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:** [August 27, 2024, 1:11pm UTC](https://community.fly.io/t/503-using-fly-machine-id-cookie/21430/3 "2024-08-27T13:11:46Z")

</div>

Closed on August 27, 2024, 1:11pm UTC

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