[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.


1) First make sure that SELinux is in enforcing mode

setenforce 1
sestatus | grep -i mode


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


httpd_can_network_connect --> on

That's All!

Share on Facebook3Share on Google+0Tweet about this on TwitterShare on StumbleUpon1Share on LinkedIn0Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

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