Laravel: Symfony\Component\Mailer\Exception\TransportException: Connection could not be established with host "smtp.mailtrap.io:2525": stream_socket_client(): Unable to connect
Laravel's mailer could not connect to the SMTP host configured in .env.
Connection could not be established with hostSymfony\Component\Mailer\Exception\TransportException: Connection could not be established with hostSwift_TransportException: Connection could not be established with hoststream_socket_client(): Unable to connect to ssl://smtpConnection refused #111 mailer Meaning
Check MAIL_MAILER, MAIL_HOST, MAIL_PORT, MAIL_ENCRYPTION and credentials, then clear the config cache — php artisan config:clear — because .env changes are ignored while config is cached. Also confirm the server can reach the host/port (firewall, DNS).
Common causes
- Wrong MAIL_HOST or MAIL_PORT in
.env - Config cached, so new
.envvalues are ignored - Outbound SMTP port blocked on the server
- Wrong encryption (tls vs ssl)
- DNS resolution failing on the host
⚡ Quick fix
- Run
php artisan config:clearafter editing.env - Verify values:
php artisan tinker→config('mail') - Test the port with
nc -vz host port
Detailed fix by platform
Laravel
php artisan config:clear && php artisan cache:clearthen retry
Code examples
.env for SMTP
MAIL_MAILER=smtp
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=user@example.com
MAIL_PASSWORD=app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@example.comHow to diagnose
- Config — config('mail') shows expected values?
- Cache — config cached?
- Network — Port reachable?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 419 Page Expired Laravel: 419 Page Expired (CSRF token mismatch)
- 421 4.7.0 Try again later (rate limited) SMTP: 421 4.7.0 Our system has detected an unusual rate of unsolicited mail originating from your IP address. Mail sent from your IP address has been temporarily rate limited
- 450 4.7.1 Greylisted, please try again later SMTP: 450 4.7.1 <user@example.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/example.com.html
Most viewed in Email / SMTP
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026