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

18 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 29 de Ag. de 2025 a las 0:00
Editada: MathWorks Support Team el 29 de Ag. de 2025 a las 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".

Más respuestas (0)

Categorías

Más información sobre MATLAB Web App Server en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by