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

19 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 26 Juil 2023
Modifié(e) : MathWorks Support Team le 29 Août 2025 à 18:36
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.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 29 Août 2025 à 0:00
Modifié(e) : MathWorks Support Team le 29 Août 2025 à 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".

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Web App Server dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by