Skip to content
Google Apps Script · error message

Apps Script: We're sorry, a server error occurred

RetryableGoogle service errors

Last verified

The exact message
Exception: We're sorry, a server error occurred. Please wait a bit and try again.

What it means

A generic failure inside a Google service call. Google's troubleshooting guide lists the related messages Server not available. and Server error occurred, please try again. and gives three possible causes: a Google server or system is temporarily unavailable, there is an error in your script that does not have a corresponding error message, or there is a bug in Apps Script.

Because the message is generic, the important question is whether it is intermittent. If the same run succeeds a minute later, it was transient. If it fails at the same line every time, something about that call (the data passed, the size of the operation, a deleted resource) is the real problem.

What it looks like

function withRetry(fn, tries = 4) {
  for (let i = 0; i < tries; i++) {
    try { return fn(); }
    catch (e) {
      if (i === tries - 1) throw e;
      Utilities.sleep(1000 * Math.pow(2, i));
    }
  }
}

Why it happens

  • A temporary problem in a Google service such as Drive, Sheets or Gmail.
  • Passing a value the service cannot handle, such as an invalid ID or an oversized payload, that has no dedicated error message.
  • Very large single operations, such as copying huge files or writing very large ranges.
  • An Apps Script platform bug affecting a specific method.

How to fix it

  1. Re-run the function after a short wait to see whether the error is transient.
  2. Check Executions for the exact line; if it is always the same call, log the arguments passed to it.
  3. Wrap the failing call in try...catch and retry with exponential backoff.
  4. Break large operations into smaller ones (fewer rows per write, smaller files).
  5. Check the Google Workspace Status Dashboard and the Apps Script issue tracker if many scripts fail at once.

How to stop it recurring

Expect occasional transient failures in any script that runs unattended. Route service calls through a retry helper with backoff, keep individual operations reasonably sized, and alert yourself on repeated failures rather than single ones.

Official documentation: developers.google.com/apps-script/guides/support/troubleshooting. See all Apps Script error messages or the Apps Script limits and quotas.

Related errors

Definitions

Quick answers

What does "We're sorry, a server error occurred" mean in Apps Script?

A generic failure inside a Google service call. Google's troubleshooting guide lists the related messages Server not available. and Server error occurred, please try again. and gives three possible causes: a Google server or system is temporarily unavailable, there is an error in your script that does not have a corresponding error message, or there is a bug in Apps Script.

How do I fix "We're sorry, a server error occurred"?

1. Re-run the function after a short wait to see whether the error is transient. 2. Check Executions for the exact line; if it is always the same call, log the arguments passed to it. 3. Wrap the failing call in try...catch and retry with exponential backoff. 4. Break large operations into smaller ones (fewer rows per write, smaller files). 5. Check the Google Workspace Status Dashboard and the Apps Script issue tracker if many scripts fail at once.

Run the job somewhere with its own limits

If a script keeps hitting its host's quotas, an Autonoly workflow can run the same steps on a schedule in an isolated cloud container, and the AI agent has a terminal with Python for steps that need code. Autonoly has limits of its own, priced in credits.

Also see Agent terminal & SSH.