n8n - ✅(Solved) Fix Environments: expired Git HTTPS token prevents n8n startup after restart [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#28311Fetched 2026-04-11 06:30:52
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
1
Timeline (top)
labeled ×3commented ×1mentioned ×1subscribed ×1

Error Message

{"level":"error","message":"Error: remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n\n at Object.action (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:42:29)\n at PluginStore.exec (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/plugin-store.ts:54:29)\n at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:124:42\n at new Promise (<anonymous>)\n at GitExecutorChain.handleTaskData (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:121:14)\n at GitExecutorChain.attemptRemoteTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:97:40)\n at processTicksAndRejections (node:internal/process/task_queues:103:5)\n at GitExecutorChain.attemptTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:61:18)","metadata":{"file":"start.js","function":"catch","timestamp":"2026-04-03T08:34:27.230Z"}} {"level":"error","message":"Exiting due to an error.","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}} {"level":"error","message":"remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}}

Root Cause

After some time, the GitHub token used for the HTTPS remote expired. Once n8n-web restarted, it failed to start because it tried to connect to the Git remote during startup and exited on authentication failure.

PR fix notes

PR #28422: fix(core): Handle git fetch failure during source control startup

Description (problem / solution / changelog)

Summary

[!IMPORTANT]
I'd like to get more hands on this, I cannot really reproduce the issue with the steps provided because if someone has their HTTPs with git, a git folder must be already there, the way I reproduced this differed a bit from the ticket which is why I need someone to validate this with me please after watching the video below 👇

https://www.loom.com/share/c9844d430fb140188f1a1cfb91addc1a

When n8n starts with source control (Environments) configured over HTTPS and the local git folder is absent or incomplete (e.g. fresh pod, ephemeral filesystem, or manually deleted folder), it calls initRepository()trackRemoteIfReady()fetch(). If the HTTPS token is expired or revoked, the authentication error was unhandled and propagated all the way up, crashing the process on startup.

This created a recovery deadlock: the UI never became available, so users couldn't fix the credentials through the UI and had to edit the database directly.

Root cause: trackRemoteIfReady() called fetch() without a try-catch, unlike the sibling method ensureBranchSetup() which already handles fetch errors gracefully.

Fix: Wrap the fetch() call in trackRemoteIfReady() with the same try-catch pattern used in ensureBranchSetup() — log a warning and return early, letting sanityCheck() surface the error once the instance is up.

How to reproduce:

  1. Configure source control with a GitHub HTTPS remote and token
  2. Revoke the token
  3. Delete the local git folder (~/.n8n/gitFolder or equivalent)
  4. Restart n8n — observe startup crash
  5. With this fix: n8n starts, logs a warning, and the user can fix credentials via the UI

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/LIGO-453 closes https://github.com/n8n-io/n8n/issues/28311

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

Changed files

  • packages/cli/src/modules/source-control.ee/__tests__/source-control-git.service.test.ts (modified, +43/-1)
  • packages/cli/src/modules/source-control.ee/source-control-git.service.ee.ts (modified, +15/-4)

Code Example

remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/[redacted]'

---

{"level":"error","message":"Error: remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n\n    at Object.action (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:42:29)\n    at PluginStore.exec (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/plugin-store.ts:54:29)\n    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:124:42\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:121:14)\n    at GitExecutorChain.attemptRemoteTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:97:40)\n    at processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at GitExecutorChain.attemptTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:61:18)","metadata":{"file":"start.js","function":"catch","timestamp":"2026-04-03T08:34:27.230Z"}}
{"level":"error","message":"Exiting due to an error.","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}}
{"level":"error","message":"remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}}
RAW_BUFFERClick to expand / collapse

Bug Description

We use self-hosted n8n in Kubernetes and are testing the Environments feature: Understand environments

We configured the Git source according to the docs using HTTPS: Set up Git source

After some time, the GitHub token used for the HTTPS remote expired. Once n8n-web restarted, it failed to start because it tried to connect to the Git remote during startup and exited on authentication failure.

This created a recovery deadlock: the UI was unavailable because n8n-web would not boot, and the only way to recover was to edit the database directly to remove or fix the stored Git configuration.

Relevant error:

remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/[redacted]'

Full startup log excerpt:

{"level":"error","message":"Error: remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n\n    at Object.action (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/error-detection.plugin.ts:42:29)\n    at PluginStore.exec (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/plugins/plugin-store.ts:54:29)\n    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:124:42\n    at new Promise (<anonymous>)\n    at GitExecutorChain.handleTaskData (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:121:14)\n    at GitExecutorChain.attemptRemoteTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:97:40)\n    at processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at GitExecutorChain.attemptTask (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/simple-git/src/lib/runners/git-executor-chain.ts:61:18)","metadata":{"file":"start.js","function":"catch","timestamp":"2026-04-03T08:34:27.230Z"}}
{"level":"error","message":"Exiting due to an error.","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}}
{"level":"error","message":"remote: Invalid username or token. Password authentication is not supported for Git operations.\nfatal: Authentication failed for 'https://github.com/[redacted]'\n","metadata":{"file":"error-reporter.js","function":"defaultReport","timestamp":"2026-04-03T08:34:27.231Z"}}

To Reproduce

  1. Run self-hosted n8n in Kubernetes.
  2. Enable and configure the Environments feature with a GitHub remote over HTTPS, using a token for authentication.
  3. Let the token expire, revoke it, or otherwise make it invalid.
  4. Restart the n8n-web instance/pod.
  5. Observe that n8n-web fails during startup because Git authentication fails.
  6. Observe that the instance cannot be recovered through the UI because the UI never becomes available.

Expected behavior

If the configured Git remote becomes temporarily invalid, n8n-web should still start.

Invalid Git credentials should be handled as a recoverable error, for example by:

  • starting normally and surfacing the Git problem in the UI/logs
  • marking the source control connection as unhealthy
  • allowing the user to update credentials or disconnect the Git source without direct database edits

It should not be possible for an expired Git token to block the whole instance from starting.

Debug Info

Debug info

core

  • n8nVersion: 2.11.3
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.13.1
  • nodeEnv: production
  • database: postgres
  • executionMode: scaling (multi-main)
  • concurrency: -1
  • license: enterprise (production)

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: database

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/146.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2026-04-10T10:36:03.373Z

Operating System

Linux (containerized deployment on Kubernetes/GKE)

n8n Version

2.11.3

Node.js Version

24.13.1

Database

PostgreSQL

Execution mode

queue

Hosting

self hosted

extent analysis

TL;DR

Update the expired GitHub token used for the Git remote or modify n8n-web to handle invalid Git credentials as a recoverable error.

Guidance

  • Check the GitHub token expiration and update it if necessary to prevent authentication failures.
  • Consider modifying the n8n-web configuration to handle Git authentication errors as non-fatal, allowing the instance to start and surfacing the issue in the UI or logs.
  • Review the n8n documentation for any recommendations on handling expired tokens or Git authentication errors in a self-hosted environment.
  • If direct database edits are required for recovery, ensure that the necessary permissions and backups are in place to minimize downtime and data loss.

Example

No code snippet is provided as the issue is related to configuration and authentication rather than code.

Notes

The provided information suggests that the issue is specific to the self-hosted n8n environment and the use of an expired GitHub token for Git authentication. The solution may involve updating the token, modifying the n8n-web configuration, or implementing additional error handling mechanisms.

Recommendation

Apply a workaround by updating the expired GitHub token or modifying the n8n-web configuration to handle invalid Git credentials as a recoverable error, as this will allow the instance to start and minimize downtime.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

If the configured Git remote becomes temporarily invalid, n8n-web should still start.

Invalid Git credentials should be handled as a recoverable error, for example by:

  • starting normally and surfacing the Git problem in the UI/logs
  • marking the source control connection as unhealthy
  • allowing the user to update credentials or disconnect the Git source without direct database edits

It should not be possible for an expired Git token to block the whole instance from starting.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING