Skip to content
Latchkey

CodeQL "fatal error while running codeql database create" in CI

The CodeQL CLI ran codeql database create and the process exited abnormally. This wraps a lower-level failure: the extractor crashed, the build under it failed, or the runner ran out of memory or disk.

What this error means

The init or analyze step fails with "Encountered a fatal error while running \"...codeql database create...\"". The exit code and a trace point to the underlying extractor or build failure.

CodeQL
Error: Encountered a fatal error while running "/opt/hostedtoolcache/CodeQL/.../codeql database create ...".
Exit code was 32 and last log line was: Spawned process exited abnormally (code 1) ...

Common causes

The build under the extractor failed

For compiled languages the extractor drives your build; if that build errors, database create reports a fatal error.

The runner ran out of memory or disk mid-extraction

Large codebases can exhaust runner RAM or disk during extraction, killing the process abnormally.

How to fix it

Fix the underlying build first

  1. Read the "last log line" and exit code the error prints.
  2. Reproduce the build command it wrapped and fix the real compiler or dependency error.
  3. Re-run so database create completes over a working build.

Give the job more resources

Move the CodeQL job to a larger runner and free disk so extraction does not exhaust memory or space.

.github/workflows/codeql.yml
jobs:
  analyze:
    runs-on: ubuntu-latest-4-cores
    steps:
      - run: rm -rf "$AGENT_TOOLSDIRECTORY" || true

How to prevent it

  • Ensure the build succeeds standalone before wrapping it in CodeQL.
  • Size the runner for the codebase to avoid OOM during extraction.
  • Keep the CodeQL CLI and action up to date for extractor fixes.

Frequently asked questions

What causes ""fatal error while running ... codeql database create""?
For compiled languages the extractor drives your build; if that build errors, database create reports a fatal error.
How do I fix "fatal error while running ... codeql database create"?
Fix the underlying build first

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card