Updated: 28 September 2026 · Applies to: AlmaLinux 9 / Rocky Linux 9

semanage manages SELinux settings such as file contexts and allowed ports. On AlmaLinux 9 / Rocky Linux 9 it is in the policycoreutils-python-utils package, which minimal installations do not include.

  1. Find the package (optional): dnf provides '*/semanage'
  2. Install it: dnf install policycoreutils-python-utils
  3. Use it, for example to let MongoDB use a custom port: semanage port -a -t mongod_port_t -p tcp 27018

Useful commands

semanage port -l | grep http                       # ports allowed for web servers
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/app/uploads(/.*)?"
restorecon -Rv /var/www/app/uploads
semanage boolean -l | grep httpd                    # on/off switches for Apache/Nginx

The package also installs audit2allow and audit2why, which explain denials from the audit log.

Common examples

semanage port -a -t http_port_t -p tcp 8080        # let Apache/Nginx listen on 8080
semanage port -m -t http_port_t -p tcp 8443        # -m if the port is already assigned to another type
semanage port -d -t http_port_t -p tcp 8080        # remove it again

After a change, restart the service. If it is still blocked, run ausearch -m avc -ts recent | audit2why to see the reason.

Ucartz services for this topic

Was this answer helpful? 27 Users Found This Useful (92 Votes)