Set MATLAB Web App Server Port number to below 1024 on Linux

19 views (last 30 days)
I want to use port 80 for my web app server on Linux. But web app cannot start. It reports below error in the log file
00000014 2023-05-18 12:15:08 0x00007faf377fe700 agent::spf::legacyservicepublisher V Exception caught: Dynamic exception type: foundation::http::TCPConfigurationError
std::exception::what: Failed to open server socket on 0.0.0.0, for given port range: [80,80]
I am pretty sure port 80 is not being used by other service.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Aug 2025 at 0:00
Edited: MathWorks Support Team on 29 Aug 2025 at 18:36
By default, ip_unprivileged_port_start is set to 1024 in Linux. It defines the first unprivileged port in the network namespace. Privileged ports require root or CAP_NET_BIND_SERVICE in order to bind to them. This is why you cannot set web app server to use port 80, or any value below 1024 if you have default ip_unprivileged_port_start value.
To workaround this:
Use port forwarding with command "sudo iptables -t nat -A PREROUTING -p tcp --dport $external_port -j REDIRECT --to-ports $server_site_port". For example your web app server is set to port 9988 and you want to access it with port 80 in the url. The command is "sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 9988"
Alternatively, you can allow listening on all privileged ports using this commands "sudo sysctl net.ipv4.ip_unprivileged_port_start=0".

More Answers (0)

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!