# Local Port Management

Local port management allows you to assign custom ports to resources from the CLI. When set, custom ports assigned to resources override the ports defined for those resources in the Admin UI's [Port Overrides](/admin/resources/port-overrides.md) section. Custom ports stay assigned to a given resource until they are specifically removed.

{% hint style="warning" %}
The **Auto-Connect Service Accounts** setting (**Settings** > **Security**) is not compatible with local custom ports. Service accounts do not auto-connect as expected when the datasources in question have been assigned custom ports.
{% endhint %}

### Override Local Port Override for a Single Resource

To assign a custom port for a single resource, use the following command:

```shell
sdm connect "<RESOURCE_NAME>" <PORT_VALUE>
```

For example:

```shell
sdm connect "server1" 6543
```

You can run `sdm status "<RESOURCE_NAME>"` to verify that the port is set, like so:

```shell
sdm status "server1"
```

A successful connection returns the resource name, connection status, and port override value, as in the following example.

```shell
     SERVER           STATUS              PORT OVERRIDE       
     server1          connected           6543
```

### Remove Local Port Override for Single Resource

To remove a custom port that was assigned to a resource, use the following command:

```shell
sdm disconnect "<RESOURCE_NAME>" --delete
```

For example:

```shell
sdm disconnect "server1" --delete
```

You can run `sdm status "<RESOURCE_NAME>"` to verify that the local port override was removed, like so:

```shell
sdm status "server1"
```

A successful disconnection returns the resource name, connection status, and original port override value, as in the following example.

```shell
     SERVER           STATUS              PORT OVERRIDE       
     server1          disconnected        18444
```

### Remove Local Port Override for All Resources

To remove custom ports assigned to all resources, use the following command:

```shell
sdm disconnect --delete --all
```

Run `sdm status` to verify any local port overrides are disconnected.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.strongdm.com/users/connect/local-port-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
