# Restricting the port range used by matlab-proxy?

**URL:** <https://discourse.openondemand.org/t/restricting-the-port-range-used-by-matlab-proxy/4226>\
**Category:** General Discussion\
**Tags:** question\
**Created:** [May 1, 2025, 4:52pm UTC](https://discourse.openondemand.org/t/restricting-the-port-range-used-by-matlab-proxy/4226 "2025-05-01T16:52:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Micket](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/micket/32/829_2.png) [@Micket](https://discourse.openondemand.org/u/Micket)\
**Post date:** [May 1, 2025, 7:13pm UTC](https://discourse.openondemand.org/t/restricting-the-port-range-used-by-matlab-proxy/4226/2 "2025-05-01T19:13:21Z")

</div>

The `find_port` used by many most apps

```auto
port=$(find_port ${host})

```

really is just a convenience method defined by OOD to find an available, open, port number. You could do whatever you want here, defining a custom thing if you want as long as it produces an appropriate port number, but this function is really good as it checks if the port is in used, and will pick another if so.  
Better yet, it already supports exactly what you ask for via optional argument 2 and 3:

```auto
port=$(find_port ${host} 6000 6010)

```

if you wish to have it limited to a just a few ports.

Documentation here:

> **[Render Template — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/template.html#before-hook)**

edit: oh i just now noticed that the min\_port and max\_port default values can also be directly configured in the batch\_connect yml

> **[Basic Batch Connect Options — Open OnDemand 4.0.0 documentation](https://osc.github.io/ood-documentation/latest/reference/files/submit-yml/basic-bc-options.html)**

so i guess just do that instead of fiddling with the scripts.

---

_[View the full topic](https://discourse.openondemand.org/t/restricting-the-port-range-used-by-matlab-proxy/4226)._
