Skip to content
Back

Next.js SSR Site Times Out on First Visit After Inactivity, Then Loads Fine on Refresh

  • 0
  • Self Hosted
  • Sites
Samuel Kings
4 Jun, 2026, 11:17

Hey everyone,

I'm running a Next.js SSR site on a self-hosted Appwrite server (v1.9.0), and I've noticed a strange behavior that I'm hoping someone can help me understand.

The site is deployed through Appwrite Sites and is currently pre-launch, so it gets very little traffic.

Whenever the site hasn't been visited for a while, the first request often ends up showing an Appwrite timeout/error page (as shown in the screenshot). However, if I refresh a few seconds later, the site loads normally and works perfectly.

This feels similar to a cold-start issue, but I'd expect the initial request to simply take longer rather than eventually timing out and showing an error page.

My concern is that most visitors won't refresh after seeing an error page - they'll assume the site is broken and leave.

Has anyone else experienced this with Next.js SSR deployments on self-hosted Appwrite?

A few questions:

  • Is this expected behavior when an SSR site has been idle for some time?
  • Is there a configuration that can prevent the first request from timing out?
  • Are there recommended timeout, container, or scaling settings for self-hosted Appwrite Sites running Next.js SSR?

I'd appreciate any guidance or suggestions on what to check.

Thanks!

TL;DR
Next.js SSR site times out on first visit due to inactivity, then loads fine on refresh. Check the environment variables to adjust the inactive threshold to prevent instances from being shut down too quickly. Next.js may take longer to spin up due to resource constraints. Verify if new container spins up instantly or with a delay. Consider scaling up containers if many functions are running to allow more elements to run in parallel.
Ibaraki Douji
4 Jun, 2026, 12:26

All sites have a timeout to free up resources when not used.

To increase that there is some envs : https://appwrite.io/docs/advanced/self-hosting/configuration/environment-variables

TypeScript
_APP_COMPUTE_INACTIVE_THRESHOLD
    version >= 1.7.0 The minimum time a function or site must be inactive before it can be shut down and cleaned up. This feature is intended to clean up unused containers. Containers may remain active for longer than the interval before being shut down, as Appwrite only cleans up unused containers every hour. If no value is provided, the default is 60 seconds.

But it first seams strange that nextjs take a very long time to spin up.

Could you check for example, when you make the first request, do you see a new container spin up instantly or like 20 second after ? If it spin up instant, that might be that nextjs takes too much time to start with the resources constraints/specification it have (a 0.5cpu-0.5g might timeout where a 2cpu-2g might not)

Last small question you said it was a site, but the UI shows "function" is it a real site (and so just a UI bug showing the wrong resource), or a function ?

Samuel Kings
4 Jun, 2026, 12:48

In response to this, it's a real site. I am as clueless as to why it shows functions error

Last small question you said it was a site, but the UI shows "function" is it a real site (and so just a UI bug showing the wrong resource), or a function ?

Samuel Kings
4 Jun, 2026, 12:49

As for the container inspection, I will check this shortly

Ibaraki Douji
4 Jun, 2026, 12:56

also if you have a lot of functions and others things running, it's possible that you need to scale up a bit some containers to allow more elements to run in parallel

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more