Note: All ports mentioned in this Answer are TCP ports.
If you plan on using the MATLAB Job Scheduler as your scheduler, please see this information instead:
How do I configure MATLAB Parallel Server using the MATLAB Job Scheduler to work within a firewall?
Ports needed for all releases:
During the formation of any communicating or parallel pool job the workers will attempt to connect together using ports within a default range of 0:65535 on Windows or the default ephemeral port range on Linux. If the cluster has firewall or network access restrictions between cluster nodes then this port range can be controlled using the environment variable:
To override the default range
- For Microsoft® HPC Pack, set MPICH_PORT_RANGE in the job template with an addition to the Environments field. For example, to open a listening port in the range 30000 to 31000, add this code to the job template.
- For other third-party schedulers, set MPICH_PORT_RANGE in the communicatingJobWrapper.sh script. For example, to open a listening port in the range 29000 to 31000, add this code to the communicatingJobWrapper.sh script.
Parallel pool ports: R2023a and newer
For parallel pools, each worker will open a listening port in the default range: 27370 to 28370. During interactive parallel pools, these ports will need to be accessible from outside of the cluster. During batch pools, port access is not required from outside the cluster.
The port range is controlled by the pctconfig function or the environment variable PARALLEL_SERVER_OVERRIDE_PORT_RANGE. See the link below for more details.
Required Ports - Troubleshoot Common Problems
Internal cluster port access: R2022b and older
For communicating jobs and parallel pools the SMPD process opens a listening port in the range: 20000 to 30000. The exact port is based on the job ID. This port is only used for communication between workers. Access to this port is not required from outside of the cluster.
If the MATLAB client machine does not have the utilities needed to interact with the scheduler, then submission to the cluster will take place via ssh using port 22.
R2022b and older
Ports only need to be opened for interactive parallel pool jobs. By default, the port range needed is 27370 to 27470.
This port range can be controlled using the function pctconfig in MATLAB on the client machine.
The client machine will be expecting inbound communications on this port range from the cluster workers. The cluster workers will use ephemeral ports to make their outbound connection.
Network License Manager Ports
The Network License Manager will need 2 ports opened. These can be changed and the license file on the Network License Manager should be used to tell which port numbers are being used. By default, port 27000 and an additional random port are used on both the client and server. Additionally, workers will need to be able to connect to these listening ports to successfully request licenses. These ports can be configured please see this information: https://www.mathworks.com/matlabcentral/answers/96756-what-ports-does-the-network-license-manager-use-and-how-can-i-set-those-ports.\n
MathWorks Hosted Licensing
Port 443 for https needs to be open on for outbound communication from cluster machines if the cluster is set to use Online Licensing.
NOTE: Starting in R2019a the following name change occurred MATLAB Distributed Computing Server was renamed to MATLAB Parallel Server.