stream_socket_client(): unable to connect to smtp.mailtrap.io:2525 (Permission denied) – CentOS 7 / Mailtrap / Laravel

Problem:
After rebuilding a CentOS 7 system with a Laravel app on it, every time the app attempted to mail a notification using MailTrap, the above error got fired.

Solution:
SELinux. Again. It’s always flipping SE LINUX! The SELinux policy can block in and outbound ports and all sorts of things. It’s a git. A clever useful git.

Running `sudo sealert -a /var/log/audit/audit.log` showed the problem. If sealert isn’t possible, then tailing the audit log with `sudo tail -f /var/log/audit/audit.log` goes some way to finding the problem.

In this case a solution (being Linux there are probably 74 equally effective and largely contested solutions) was to allow Apache to use port 2525 like so:

sudo semanage port -a -t http_port_t -p tcp 2525

Any good? If this helped please let me know: Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

One thought on “stream_socket_client(): unable to connect to smtp.mailtrap.io:2525 (Permission denied) – CentOS 7 / Mailtrap / Laravel”

  1. saved my time, thank you!
    I am running CentOS6 with laravel 7. Tried other suggestions from stackoverflow, nothing helped, but you solution worked like a charm! Thanks

Leave a Reply

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