# Troubleshooting

Each section starts with what you see, then explains the cause and the fix. When a deploy fails, the version already running stays live, so you can fix the cause and deploy again.

## A build fails

`grayspar deploy` prints the end of the build log and the command that shows the rest:

```sh
grayspar logs --build
```

The log names the step that failed, such as a missing dependency or a command your build script runs. Fix the step in your code and deploy again. If the log says the build stopped because of an internal error, nothing in your code caused it, and deploying again usually succeeds.

## The deploy says a folder can't start

```text frame="terminal"
Nothing in api says how to start it.
```

Grayspar couldn't find a start command for the folder. Add a `Procfile` that names the command, as [Start command and port](/docs/deploy/start-command-and-port/#set-your-own-start-command) shows.

## The service isn't answering on its port

```text frame="terminal"
This service isn't answering on port 8080. If it uses another port, set PORT to that port.
```

The app started but never answered on the port Grayspar gave it. Two causes cover almost every case:

- The app listens on another port. Read the port from the `PORT` variable, or set `PORT` to the port your app uses with `grayspar env set PORT=3000`.
- The app listens on `localhost` alone. Listen on `0.0.0.0`, so requests from outside the service reach it.

A background worker that takes no requests needs no port. Give it no path, as [Services and paths](/docs/deploy/services-and-paths/#run-a-service-with-no-path) describes.

## Requests to a service at a path answer 404

A service at a path receives each request with that path, so a backend at `/api` receives `/api/<route>`. A backend written behind a dev proxy that removed `/api`, as Vite's `rewrite` option does, has no route for it. Mount the backend's routes under `/api`, as [Services and paths](/docs/deploy/services-and-paths/#choose-a-path) describes.

## The app crashes while starting

```text frame="terminal"
This version crashed while starting.
```

The app exited soon after it started. To read what it printed before it stopped, run:

```sh
grayspar logs
```

A missing variable is a common cause. Compare the variables your app reads with the list `grayspar env` prints.

## A variable from .env wasn't sent

A value that points at `localhost` or `127.0.0.1` stays on your computer, because a server can't reach your computer. The CLI names each variable it left out. Set its production value with a command:

```sh
grayspar env set DATABASE_URL=postgres://db.example.com/<database-name>
```

## A Dockerfile can't find its files

A Dockerfile meant to be built from the root of the repository fails when Grayspar builds it from its own folder, because the files it copies sit elsewhere. Name the Dockerfile once with `--dockerfile`, and Grayspar builds it from the root:

```sh
grayspar deploy --dockerfile api=docker/api.Dockerfile
```

## A volume is full

When a volume fills and your plan has no storage left for it to grow, the team's owners get an email saying which volume is full. Remove a volume nobody needs with `grayspar volume remove`, or delete files your app no longer needs.

## Someone can't open the project

A person who sees a page saying the project is private either isn't on the list, or logged in with a different address than the one you added. Run `grayspar access` to check the list. The page lets the person switch accounts or [ask the owners for access](/docs/sharing/access-requests/).

## A webhook never reaches the app

Services such as Stripe and GitHub can't log in, so a private project turns their requests away. Add the path they call as an [open path](/docs/sharing/open-paths/):

```sh
grayspar open-path add /webhooks
```

## Requests answer 429 Too Many Requests

Grayspar answers 429 when one address sends a project more than a burst of 500 requests, then more than 50 a second. The `Retry-After` header says how many seconds to wait. A person opening the app never comes near it, but a script or a load test can, so pace it below 50 requests a second.

## The CLI asks a question an agent can't answer

Without a terminal, the CLI turns each question into a refusal that names the flag answering it, such as `--yes` or `--path`. Add the flag and run the command again. [Grayspar for agents](/docs/agents/#how-agents-use-the-cli) shows what a refusal looks like.