I am wrote a systemd unit to start gunicorn but it unfortunately kept failing, upon checking journalctl I found the following error.

SELinux is preventing /usr/lib/systemd/systemd from execute access on the file gunicorn.

Ideally I would like to avoid having to disable SElinux as its an added security layer.

How can I tell SElinux to allow gunicorn without having to totally disable SElinux?

Any suggestions / insight would be very much appreciated, thanks.


If you are using Red Hat (or something derived from it, like Centos or Scientific Linux) you can install the policycoreutils-python and setroubleshoot-server packages with yum, which will give you some powerful diagnostic tools.

From the sounds of it, and without knowing your distribution details, you probably need to set the selinux context on the file gunicorn so that systemd is allowed to use it. You can see the current context with ls -Z [filepath]

  • thanks I'll definitely have alook into that. – Lawless Leopard Apr 1 '20 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.