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

Edit crontab with NANO on centos (crontab -e)

Problem: I don’t know where my root users crontab file is, and this doesn’t usually matter because using the command ‘crontab -e’ opens it for editing anyway… but it opens in VI and I am too stupid / lazy / in a rush to use VI.

[Edit – mid 2018: Earlier this year I went through about 3 weeks of IDE/Editor hell and taught myself Vim. It’s… wonderful]

Solution: The -e switch makes the file open in whatever the default editor for the environment is. To override this, pass the EDITOR environment var to the command when it’s run:

sudo env EDITOR=nano crontab -e

Please let me know if this nano tip was useful, just one click!
Nope, not helpful...Yep, more useful than not! - +83 thumb, 109 overall.
Loading...