---
title: req.backend
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/req-backend
---

**Type:** BACKEND  
**Access:** can be read and set, but not unset

**Available in:** all subroutines

The backend to use if the request is forwarded to origin.

> **HINT:** If you want to log or otherwise report on which backend was used for a request, consider using `req.backend.name` instead.

Since the type of this variable is `BACKEND`, an assignment must use one of the defined backends within your Fastly service.  Backends defined within the web interface are prefixed with `F_` when referencing them in VCL. For example:

```vcl
set req.backend = F_primary_origin;
```

It's possible to see all the defined backends in your service by viewing the service's generated VCL, either via [the API](https://www.fastly.com/documentation/reference/api/vcl-services/vcl/#get-custom-vcl-generated) or using the web interface.

Upon reading in a `STRING` context, `req.backend` is converted to a `STRING` and prepended with the backend's `share_key` property, which by default is your service ID, but can be changed as part of the backend definition to [consolidate healthcheck traffic](https://www.fastly.com/documentation/guides/concepts/healthcheck/#understanding-health-check-traffic-volume).

While this variable is accessible in all VCL subroutines, it is always `null` in `vcl_log`, and is reported inaccurately in `vcl_deliver` as a side effect of internal Fastly routing.  To access the value of `req.backend` in `vcl_deliver` or `vcl_log`, copy the value into a custom HTTP header earlier in your VCL program.
