# IPortAllocator

- Kind: `interface`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/a3766e994fd2cba86c8ac60b8a80268cab7e6383/src/Aspire.Hosting/ApplicationModel/IPortAllocator.cs)

Provides port allocation functionality for resources.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public interface IPortAllocator
{
    // ...
}
```

## Methods

- [AddUsedPort(int)](/reference/api/csharp/aspire.hosting/iportallocator/methods.md#addusedport-int) `abstract` -- Marks a port as used to prevent it from being allocated.
- [AllocatePort](/reference/api/csharp/aspire.hosting/iportallocator/methods.md#allocateport) : `int` `abstract` -- Allocates a port that is not currently in use.
