The error message "Failed to open server socket on 0.0.0.0, for given port range: [9988,9988]" in the log file indicates that port 9988 is not available for use by the webapps process. It may be occupied by another process, blocked by a firewall, or restricted as a privileged port.
On Windows
To check if a port is available on Windows, open Resource Monitor from the start menu and go the Network tab. Under Listening Ports, check if another process is listening on the port you want to use. You can then find more information or terminate the process by searching the corresponding PID in Task Manager.
For example, the screenshot below shows port 9988 is already occupied by a process, webapps.exe. In the Task Manager app, we can search the PID 12280 and see that this process is associated with MATLAB Web App Server R2022b. If you are attempting to start a different release of MATLAB Web App Server, use webapps-stop to stop the running server to free up this port, or use webapps-config to configure your preferred release to use a different port.
Task Manager
On Linux
On Linux, you can use command "sudo lsof -i:PORT_NUMBER" to check if any other applications are listening on the port.
For example, the below result shows that port 9988 is being used by MATLAB Web App Server R2022a. If you are installing a new release, you should stop the older server first or use a different port.
% sudo lsof -i:9988
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
webapps 29354 MwWebAppsServerR2022a 24u IPv4 5064978 0t0 TCP *:9988 (LISTEN)
webapps 29354 MwWebAppsServerR2022a 31u IPv4 5067959 0t0 TCP myserver.com:9988->myserver.com:49840 (ESTABLISHED)
webapps 29354 MwWebAppsServerR2022a 32u IPv4 5067985 0t0 TCP myserver.com:9988->myserver.com:49844 (ESTABLISHED)
If the command returns nothing, it indicates that the port is not in use by any other process. If this is the case but you are still receiving the same error, the port could be blocked by a firewall. Check your firewall configuration to ensure that the port you intend to use is not blocked.
Also note that all ports in the range 1 to 1024 are considered "privileged" ports on Linux systems. By default, only processes running as root can bind to privileged ports. If you would like to use MATLAB Web App Server with one of these ports, there are several options for workarounds:
- Allow the webapps service to bind to privileged ports:
sudo setcap 'cap_net_bind_service=+ep' /path/to/webapps
- Set up port forwarding to route traffic through a different port. For example, if you want your users to access MATLAB Web App Server on port 443 but leave your server configured to use non-privileged port 9988, you can route traffic from port 433 to port 9988 as follows:
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 9988