# 60 second timeout for HTTP server

**URL:** <https://community.fly.io/t/60-second-timeout-for-http-server/1243>\
**Category:** Questions / Help\
**Created:** [April 23, 2021, 4:49pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243 "2021-04-23T16:49:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewrobertbell](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/matthewrobertbell/32/574_2.png) [@matthewrobertbell](https://community.fly.io/u/matthewrobertbell)\
**Post date:** [April 23, 2021, 4:49pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/1 "2021-04-23T16:49:08Z")

</div>

Hi,

I have a test project, which uses Flask’s testing server for now. The only route does substantial processing, which can take more than 60 seconds.

When I run it locally, it works fine. When I run it on Fly, if the processing takes more than 60 seconds the request times out.

Is this a setting that I’ve missed? I didn’t see anything in the docs.

Thanks!

---

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [April 23, 2021, 4:57pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/2 "2021-04-23T16:57:02Z")

</div>

Hey there!

Edit: There isn’t a idle timeout anymore.

~~There is a 60 _idle_ timeout. If no data is received or sent within 60 seconds, the connection will be closed.~~

~~This is not well documented (if at all). We could bring that up a bit, but there are other options that might work for you:~~

- ~~Use polling instead of 1 long request. Immediately respond with a 202 (Accepted) HTTP response code and then have your client poll your server every 5 seconds to get the status of your “job”.~~
- ~~Send back data through the connection to keep it alive.~~

~~The choice of `60s` is pretty arbitrary, we could make `120s` work! However, if you ever have a job that takes over 120s, then you’re left with the same problem.~~

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [April 23, 2021, 5:06pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/3 "2021-04-23T17:06:03Z")

</div>

One option I’m really fond of is streaming responses: [Streaming Contents — Flask Documentation (1.1.x)](https://flask.palletsprojects.com/en/1.1.x/patterns/streaming/)

That 60s timeout resets when you send any data at all, so if the work you’re doing can stream data incrementally it lets you run requests as long as necessary.

If you can’t send data incrementally, it’s sometimes worth sending the equivalent of a ping through the stream. [SSE](https://flask-sse.readthedocs.io/en/latest/quickstart.html) handles this for you if it’s an option.

---

<div class="post-metadata">

**Author:** ![matthewrobertbell](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/matthewrobertbell/32/574_2.png) [@matthewrobertbell](https://community.fly.io/u/matthewrobertbell)\
**Post date:** [April 23, 2021, 5:47pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/4 "2021-04-23T17:47:15Z")

</div>

Thank you both. Streaming " " every second before streaming the result JSON then closing the stream worked.

It’d be great to have the idle timeout be configurable.

It’d also be great to have worker VMs that run from a queue and are autoscaled (scaling down when idle). Happy to beta test anything like that which is in the works 🙂

---

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [April 25, 2021, 2:26pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/5 "2021-04-25T14:26:43Z")

</div>

There are limits to the idle timeout we’ll accept, we have to protect host resources (there is a maximum number of open connections we can handle at any given time).

We might be able to bump the timeout up, but it seems like 60s works for most cases!

We could make it configurable to a point, maybe within the range of 0s - 120s. There are some use cases where a lower timeout might be desirable.

---

<div class="post-metadata">

**Author:** ![matthewford](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/matthewford/32/667_2.png) [@matthewford](https://community.fly.io/u/matthewford)\
**Post date:** [July 15, 2021, 3:47pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/6 "2021-07-15T15:47:35Z")

</div>

Hi @jerome

Would it be possible to configure the idle timeout?

I’m porting a few rails apps which we have not yet changed to stream responses, and having a higher timeout will allow to us to switch while we refractor the apps.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jerome/32/17_2.png) [@jerome](https://community.fly.io/u/jerome)\
**Post date:** [July 15, 2021, 5:10pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/7 "2021-07-15T17:10:43Z")

</div>

> [@matthewford](#):
>
> Would it be possible to configure the idle timeout?

It’s not currently possible. The limit is there to protect our server resources (max open file descriptors).

There are ideas floating around to make that limit higher or disable it for organizations with a large-enough scale (who are, therefore, paying more for our services). This makes sense because we’d know we can “trust” these apps not to try to exhaust our server resources.

> [@matthewford](#):
>
> I’m porting a few rails apps which we have not yet changed to stream responses, and having a higher timeout will allow to us to switch while we refractor the apps.

What value for the idle timeout were you thinking of configuring?

---

<div class="post-metadata">

**Author:** ![matthewford](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/matthewford/32/667_2.png) [@matthewford](https://community.fly.io/u/matthewford)\
**Post date:** [July 15, 2021, 5:26pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/8 "2021-07-15T17:26:25Z")

</div>

120 would work for us, could this be higher on larger vm’s for example?

---

<div class="post-metadata">

**Author:** ![artyroip](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/artyroip/32/35261_2.png) [@artyroip](https://community.fly.io/u/artyroip)\
**Post date:** [April 20, 2022, 11:36pm UTC](https://community.fly.io/t/60-second-timeout-for-http-server/1243/9 "2022-04-20T23:36:15Z")

</div>

Is there any update on this?
