# A build fails

Source: https://openpanel.sh/docs/troubleshooting/build-fails

Why a build from Git fails, where to read its output, and what to do about each message.

When a build fails, the deployment's status is `failed` and its `error` starts with "The build failed:", followed by the last line the build printed. What ran before keeps running.

## Read the build's output [#read-the-builds-output]

```sh
openpanel deployments get "$DEPLOYMENT_ID"
openpanel logs --deployment "$DEPLOYMENT_ID"
```

The first shows the error; the second prints the deployment's events, with the build's output in batches of up to 500 lines, for two days after the build. Through the API, read `GET /deployments/{id}` and `GET /deployments/{id}/events`. See [How builds work](/docs/builds#build-output).

## Messages [#messages]

| The error says | What it means | What to do |
|---|---|---|
| "clone: …" with "Remote branch … not found" | The branch does not exist in the repository. | Fix the service's branch. In the CLI, `--branch` goes with `--repo` and `--git-account`, since they change the source as a whole: `openpanel services update web --repo acme/shop --git-account "$GIT_ACCOUNT_ID" --branch main`. |
| "clone: …" or "fetch: …" with "Authentication failed", "could not read Username" or "Permission denied (publickey)" | The Git account cannot read the repository. | Check the account on the console's **Git accounts** page. Add its deploy key to the repository, or remove the account and add it again with a token that can read the repository. See [Git accounts](/docs/git). |
| "checkout 3f9c2a1: …" | The commit you deployed is not in the repository, or not on the branch. | Check the hash, or deploy without `--commit`. |
| "the repository gave commit …, not …" | The hash you gave matches a different commit than you meant. | Give more of the hash. |
| "… is not in the repository" | The service's folder, the Dockerfile or its context does not exist in the commit that was built. | Fix the service's folder (`--path`, with `--repo` and `--git-account`) or the Dockerfile's path. See [Dockerfile builds](/docs/builds/dockerfile). |
| "… leads out of the repository" | A path, or a symbolic link on it, points outside the clone. | Use a path inside the repository. |
| "there is no Dockerfile at …" | The Dockerfile's path names a folder. | Point it at the file. |
| "railpack: …" | Railpack could not work out how to build the folder. | Check that the folder has the files that mark its language, or add a `railpack.json`, or build with a Dockerfile. See [Languages and frameworks](/docs/builds/languages). |
| "download railpack: …" or "railpack's checksum does not match the pinned one" | The server could not fetch Railpack from GitHub, or got a file other than the release. Nothing was installed. | Check that the server reaches `github.com` over HTTPS, then deploy again. |
| "build: …" | Docker's build stopped, for example because a command in your Dockerfile or your project's own build failed. | Read the output above the last line, fix the project, and deploy again. |
| "timed out after 30m0s" | The build ran for longer than 30 minutes. | Make the build faster, for example with a smaller build context or fewer steps, or build the image in your CI and [deploy it as an image](/docs/deploy/images). |
| "The build did not finish within 60 minutes." | The build never ended, usually because the server's agent was offline. | Check the server's status, then deploy again. |

If the build itself ran but the deployment still failed, the problem is in starting the containers: see [A deploy or a health check fails](/docs/troubleshooting/deploy-fails).

## Variables during the build [#variables-during-the-build]

Your service's variables are not given to the build. If your build reads one, such as an address a framework puts into its pages, it gets nothing. See [How builds work](/docs/builds#variables-do-not-reach-the-build).

## Still stuck [#still-stuck]

[Get help](/docs/troubleshooting/get-help), and send the deployment's id and its error.