# YarpResource.WithHostPort

- Module: [Aspire.Hosting.Yarp](/reference/api/go/aspire.hosting.yarp.md)
- Defined on: [YarpResource](/reference/api/go/aspire.hosting.yarp/yarpresource.md)
- Version: `17.0.0`
- Kind: `method`

Configures the host port that the YARP resource is exposed on instead of using randomly assigned port.

## Definition

```go
type YarpResource interface {
    // ... omitted for brevity
    WithHostPort(port *float64) YarpResource
}
```

## Signature

```go
WithHostPort(port *float64) YarpResource
```

## Parameters

- `port` (`*float64`) -- The port to bind on the host. If `null` is used random port will be assigned.

## Returns

[`YarpResource`](/reference/api/go/aspire.hosting.yarp/yarpresource.md)

Returns a handle; failures surface later via `Err()`.

## Defined on

- [YarpResource](/reference/api/go/aspire.hosting.yarp/yarpresource.md) -- `handle`
