Lesstep
Forgejo · Gitea · Codeberg · merge API · Checked October 24, 2026

Forgejo and Gitea: why the merge was refused

When a merge through the API (POST /api/v1/repos/OWNER/REPO/pulls/NUMBER/merge) fails, Forgejo and Gitea answer 405 or 409, and the JSON's message says why. From the source of both (MergePullRequest in routers/api/v1/repo/pull.go, and the checks in services/pull): 405 means that a check stopped the merge before it started, and 409 that the server tried and the merge failed, or that the branch moved since you looked. The wording below is the current source of both; older servers may word it differently.

405: a check stopped it

The checks run in this order, and the first one that fails answers:

To see where a pull request stands, read it:

curl -H "Authorization: token your-token" https://codeberg.org/api/v1/repos/OWNER/REPO/pulls/42

mergeable is false while the server is checking it, while it conflicts, after an error in that check, and while it is a work in progress. Use your own server's address instead of codeberg.org. Asking with merge_when_checks_succeed instead schedules the merge for when the checks pass (201): the branch protection checks do not stop that request. See what a scheduled merge waits for, and what still refuses it.

409: the merge was tried and failed

A 500 with an empty message, once the other checks pass, means the pull request depends on an issue or pull request that is still open: the server shows that reason only to administrators. Close that one or remove the dependency (more on it).

What to do

Forgejo and Gitea pull requests in IntelliJ IDEA

Pull Request Inbox for Forgejo and Gitea, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, shows a pull request's merge checks before you merge, with the ones that block the merge first: work in progress, approvals against the count the branch requires, requested changes, the required checks, conflicts, a target branch with new commits, and whether the branch lets your account merge. It merges the head commit you had on screen. When the server answers "Please try again later" right after a push, it asks again for a few seconds. When the server refuses, it says so: for 405, that the server cannot merge it now, with the server's words, and to see the merge checks; for 409 "head out of date", that the branch changed and to refresh; from version 1.0.14, for the other 409s, that the branches conflict or share no history, or the server's words; from version 1.0.17, for a 500 with no message, that an open dependency blocks the pull request. It can also merge when the checks succeed and update the branch. Reading is free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).

Forgejo, Gitea and Codeberg are names of their respective owners; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by the Forgejo project, Codeberg e.V., the Gitea project or JetBrains.

More: Forgejo and Gitea merge when checks succeed refused (405, 409, 500) · Forgejo and Gitea required checks (missing, skipped, patterns) · 404 "The target couldn't be found." and "not found" · 401 "token is required" and unknown tokens · "token does not have at least one of required scope(s)" · Forgejo and Gitea review refused (422) · Forgejo and Gitea branch update refused (403, 409, 422) · Forgejo and Gitea pull request not created (409, 422, 403) · Forgejo and Gitea comment refused (403, 422, 400) · Forgejo and Gitea search refused (400, 422) · Forgejo and Gitea pull request files (pages of 50, changed_files) · Forgejo and Gitea pull request plugins for IntelliJ IDEA, compared · 日本語