Run semanage command to make a change in SELinux policy to allow us access to MongoDB on port 27017.

semanage port -a -t mongod_port_t -p tcp 27017


To my surprise, I got an error.

-bash: semanage: command not found



semanage is used to configure certain parts of SELinux policy without requiring modification to or recompilation from policy sources.


This small post will help you to install the necessary packages for getting semanage command. Let us see which package provides us ifconfig command using the YUM command.

yum whatprovides semanage


yum provides *bin/semanage



Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
base/7/x86_64/filelists_db                                                          | 6.7 MB  00:00:01
extras/7/x86_64/filelists_db                                                        | 528 kB  00:00:00
nginx/x86_64/filelists_db                                                           |  39 kB  00:00:00
updates/7/x86_64/filelists_db                                                       | 3.1 MB  00:00:00
policycoreutils-python-2.5-17.1.el7.x86_64 : SELinux policy core python utilities
Repo        : base
Matched from:
Filename    : /usr/sbin/semanage


From the above command output, you can see that policycoreutils-python package provides you semanage command. Now, install the policycoreutils-python package using the YUM command.

yum -y install policycoreutils-python


Once the installation is complete, run semanage to see whether it is available or not.

semanage port -a -t mongod_port_t -p tcp 27017


Now, you should not see any errors.


That’s All.

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