# 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](https://app.gitbook.com/s/F7eka9SH5TT8nJm2ZfWj/resources/port-overrides "mention") 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.
