# Function timeout issue

**URL:** <https://answers.netlify.com/t/function-timeout-issue/91818>\
**Category:** Support\
**Tags:** netlify-newbie, nextjs, deployment\
**Created:** [May 8, 2023, 3:37am UTC](https://answers.netlify.com/t/function-timeout-issue/91818 "2023-05-08T03:37:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickCoin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rickcoin/32/50608_2.png) [@rickCoin](https://answers.netlify.com/u/rickCoin)\
**Post date:** [May 8, 2023, 3:37am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/1 "2023-05-08T03:37:57Z")

</div>

Hi Netlify Support teams.  
I have built a webapp by nextjs.  
I’m running into an issue while waiting for an API response.  
It seems that if the API response time exceeds 10 seconds, a 502 error will be raised.

 ![image](https://global.discourse-cdn.com/netlify/original/3X/a/8/a82239faf59a2bfb46b58381ab02b561b9440102.png)

However, when I run the app on the localhost, it still works fine even if the response time exceeds 10 seconds.

Is this the same issue as the one previously mentioned?

> [@Timeout 10 Seconds](https://answers.netlify.com/t/timeout-10-seconds/83146):
>
> I am trying to develop an app in NextJS which makes a call to openAI. the call takes 20 seconds, I have placed this inside a nextjs api route. I was using vercel to start with and I tried netifly to see if they allowed this, but they don’t either… Is there any workaround for this? Cheers

BTW, the API I used is also openAI’s API but I runing the API service at GCP.

my site name: darling-gumption-95e739

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 3:58am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/2 "2023-05-08T03:58:20Z")

</div>

> [@rickCoin](#):
>
> However, when I run the app on the localhost, it still works fine even if the response time exceeds 10 seconds.

When running a function using Netlify CLI, the same 10 second limit applies and will throw the same error as it does in production.

> [@rickCoin](#):
>
> BTW, the API I used is also openAI’s API but I runing the API service at GCP.

Is the API made from a Netlify function or the the path `/api/*` proxied to GCP? If it is proxied, then the response is not returned from Netlify _(Netlify will return whatever is returned from the proxy endpoint.)_

---

<div class="post-metadata">

**Author:** ![rickCoin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rickcoin/32/50608_2.png) [@rickCoin](https://answers.netlify.com/u/rickCoin)\
**Post date:** [May 8, 2023, 5:57am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/3 "2023-05-08T05:57:23Z")

</div>

Thank you for the quick reply.

The API is made from `/api/*` proxied to GCP, I did not use Netlify function.

Do you mean that the 10-second limit would not apply to requests made to endpoints under the `/api/*` path?

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 6:10am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/4 "2023-05-08T06:10:21Z")

</div>

> [@rickCoin](#):
>
> Do you mean that the 10-second limit would not apply to requests made to endpoints under the `/api/*` path?

Exactly. The 10 second limit only applies to Netlify functions.

Proxy rewrites have a timeout is 30 seconds _(which is a fairly long time in terms of web requests)_ as mentioned [here](https://answers.netlify.com/t/timeout-when-posting-large-file-data-to-external-api-using-a-proxy-rewrite/41387/5). But I doubt this is the issue.

The `502` error is likely coming from the GCP endpoint, Netlify is simply passing it through to the Axios call.

---

<div class="post-metadata">

**Author:** ![rickCoin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rickcoin/32/50608_2.png) [@rickCoin](https://answers.netlify.com/u/rickCoin)\
**Post date:** [May 8, 2023, 7:30am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/5 "2023-05-08T07:30:41Z")

</div>

Thanks again!

I just want to confirm that I understand correctly. I have created a file called ‘photographic.ts’ under the ‘/pages/api/’ folder, and in ‘photographic.ts’, I’m calling the real API that I have implemented in GCP. Does above work call “Proxy rewrites”?

Also, I have tested the API implemented from GCP on Postman and it works normally.  
Does that mean the timeout of Proxy rewrites in nextjs is not 30 seconds?  
Usually, the API takes 10-20 seconds to respond.

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 8:24am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/6 "2023-05-08T08:24:23Z")

</div>

Thanks for the extra details. What you have described as I understand [Next.js on Netlify](https://docs.netlify.com/integrations/frameworks/next-js/overview/) is yes this is a function, not a [rewrite/proxy](https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service).

This would mean the 10 second limit applies.

> [@rickCoin](#):
>
> Also, I have tested the API implemented from GCP on Postman and it works normally.

There is clearly a discrepancy between this test and the real-world deployed function. Is there perhaps an environment variable _( **e.g.** API key)_ that is missing from the deploy? Have you tried adding logging to the function to see what is returned from the call or if the call is even made?

I am not a Next.js expert by any stretch of the imagination so I can’t guide you toward any specifics.

---

<div class="post-metadata">

**Author:** ![rickCoin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/rickcoin/32/50608_2.png) [@rickCoin](https://answers.netlify.com/u/rickCoin)\
**Post date:** [May 8, 2023, 8:45am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/7 "2023-05-08T08:45:54Z")

</div>

Thaks again.

Let me confirm again: Do you mean that Next.js API routes would have the same restrictions as Netlify functions? like this one said [Netlify serverless functions vs Next.js API Routes?](https://answers.netlify.com/t/netlify-serverless-functions-vs-next-js-api-routes/76880)

If so, how to set a higher limitation for my project?

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 9:01am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/8 "2023-05-08T09:01:33Z")

</div>

> [@rickCoin](#):
>
> Do you mean that Next.js API routes would have the same restrictions as Netlify functions?

Yes.

> [@rickCoin](#):
>
> If so, how to set a higher limitation for my project?

A Netlify Support Engineer can do that for you.

However as I said earlier, I am not sure time is necessarily the cause of failure.

---

<div class="post-metadata">

**Author:** ![Jerenyaoyelu](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jerenyaoyelu/32/50614_2.png) [@Jerenyaoyelu](https://answers.netlify.com/u/Jerenyaoyelu)\
**Post date:** [May 8, 2023, 10:03am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/9 "2023-05-08T10:03:40Z")

</div>

Hi there, I am experiencing the same issue, have you resolved it? if so, how do you do that?

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 10:14am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/10 "2023-05-08T10:14:27Z")

</div>

As is mentioned in the post before yours @Jerenyaoyelu, only a Netlify staff member can increase the function execution limit.

---

<div class="post-metadata">

**Author:** ![Jerenyaoyelu](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jerenyaoyelu/32/50614_2.png) [@Jerenyaoyelu](https://answers.netlify.com/u/Jerenyaoyelu)\
**Post date:** [May 8, 2023, 10:16am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/11 "2023-05-08T10:16:24Z")

</div>

which means there is no approach for us to overcome this limit?

---

<div class="post-metadata">

**Author:** ![jasiqli](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jasiqli/32/38220_2.png) [@jasiqli](https://answers.netlify.com/u/jasiqli)\
**Post date:** [May 8, 2023, 10:29am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/12 "2023-05-08T10:29:24Z")

</div>

No, there is nothing you, as a user, can do other than politely ask for an increase in time.  
See [Custom Deployment Options](https://docs.netlify.com/functions/overview/#custom-deployment-options) for more information.

---

<div class="post-metadata">

**Author:** ![Melvin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/melvin/32/23606_2.png) [@Melvin](https://answers.netlify.com/u/Melvin)\
**Post date:** [May 8, 2023, 12:44pm UTC](https://answers.netlify.com/t/function-timeout-issue/91818/13 "2023-05-08T12:44:17Z")

</div>

Hi @Jerenyaoyelu,

Could you provide us with the site name (such as sitename.netlify.app) of the site you want to increase the function timeout?

---

<div class="post-metadata">

**Author:** ![Jerenyaoyelu](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/jerenyaoyelu/32/50614_2.png) [@Jerenyaoyelu](https://answers.netlify.com/u/Jerenyaoyelu)\
**Post date:** [May 9, 2023, 2:48am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/15 "2023-05-09T02:48:54Z")

</div>

hi @Melvin, pieces-sam.netlify.app I am in the free plan.

---

<div class="post-metadata">

**Author:** ![Melvin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/melvin/32/23606_2.png) [@Melvin](https://answers.netlify.com/u/Melvin)\
**Post date:** [May 9, 2023, 3:35pm UTC](https://answers.netlify.com/t/function-timeout-issue/91818/16 "2023-05-09T15:35:10Z")

</div>

Hi @Jerenyaoyelu,

In order to increase the functions timeout limit for the site, the account will need to be on the [Pro Team plan](https://www.netlify.com/pricing/) (or above).

If you upgrade to the Pro Team plan or above, please let us know and we’ll be able to increase the Functions timeout limit to 26 seconds (max time).

---

<div class="post-metadata">

**Author:** ![vishnukool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/vishnukool/32/68233_2.png) [@vishnukool](https://answers.netlify.com/u/vishnukool)\
**Post date:** [March 16, 2025, 6:40am UTC](https://answers.netlify.com/t/function-timeout-issue/91818/17 "2025-03-16T06:40:55Z")

</div>

Can you please incerease timeout to max for me as well

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 16, 2025, 5:11pm UTC](https://answers.netlify.com/t/function-timeout-issue/91818/18 "2025-03-16T17:11:03Z")

</div>

Kindly do not duplicate yourself.
