> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic job restarts

By default, a job runs once and isn't restarted. You can set up a job to be automatically restarted when its container exits with an error.

<Note>
  Automatic restarts aren't available for Serverless AI endpoints.
</Note>

## Configuring automatic restarts

To turn automatic restarts on or off for a job, set the `--restart-policy` parameter when you [create the job](/serverless/jobs/manage#how-to-create-a-job):

| Value        | Behavior                                                                                                           |
| ------------ | ------------------------------------------------------------------------------------------------------------------ |
| `never`      | Default. The job runs once. If the container exits with an error, the job is marked as failed and isn't restarted. |
| `on-failure` | If the container exits with a non-zero exit code, Serverless AI automatically restarts it.                         |

```bash theme={null}
nebius ai job create \
  --name my-job \
  --restart-policy on-failure \
  ...
```

`--restart-policy on-failure` reacts to your container exiting with an error while the job is running. This is useful for workloads that can fail transiently and succeed on a retry, for example, a training step that occasionally crashes and can resume from a checkpoint.

## When jobs aren't restarted

`--restart-policy` responds only to the container's own exit code. It does not recover from:

* **No available capacity at start**: if the requested compute can't be allocated when the job starts.
* **Preemption**: if you run on [preemptible compute](/compute/virtual-machines/preemptible) and Nebius AI Cloud reclaims (preempts) the underlying virtual machine (VM).
* **The underlying VM stopping unexpectedly**.
* **Startup failures and timeouts**.

In these cases, the job moves to the `ERROR` [status](/serverless/lifecycle) and isn't retried by `--restart-policy`. To run it again, create a new job or use [nebius ai job restart](/cli/reference/ai/job/restart).

<Tip>
  For resilience against preemption or lost capacity, design your workload to be resumable, for example, write and resume from checkpoints, and resubmit the job rather than relying on `--restart-policy`.
</Tip>
