# PostgresServerResource.WithHostPort

- Module: [Aspire.Hosting.PostgreSQL](/reference/api/go/aspire.hosting.postgresql.md)
- Defined on: [PostgresServerResource](/reference/api/go/aspire.hosting.postgresql/postgresserverresource.md)
- Version: `17.0.0`
- Kind: `method`

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

## Definition

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

## Signature

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

## Parameters

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

## Returns

[`PostgresServerResource`](/reference/api/go/aspire.hosting.postgresql/postgresserverresource.md) -- The resource builder.

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

## Defined on

- [PostgresServerResource](/reference/api/go/aspire.hosting.postgresql/postgresserverresource.md) -- `handle`
