Web Dev

[Solved] SocketException Permission denied - CakePHP

CakePHP is a PHP development framework used in many projects. CakePHP supports sending mail via built in mail functions of PHP, smtp server. One may face following error message while sending mail:

SocketException Permission denied - CakePHP

The issue is related to the SELinux policy of the OS. SELinux forbid PHP/Apache to make network connections.
In this case, one has to make an exception to allow Apache/PHP to make network.

Solution:

1) First make sure that SELinux is in enforcing mode

setenforce 1
sestatus | grep -i mode

Output:

Current mode:           enforcing
Mode from config file:  permissive

2) Execute following command to allow connection:

setsebool -P httpd_can_network_connect=1

The command will take sometime to complete execution. This setting will be permanently applied on the server.

3) Verify using following command:

getsebool httpd_can_network_connect

Output:

httpd_can_network_connect --> on

That's All!

Abhijit Sandhan

Love to Automate, Blog, Travel, Hike & spread Knowledge!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button