While working on a project this week, I was migrating a live Laravel 11 application from one production server to a DigitalOcean droplet.
I encountered an odd issue where the application insisted on sending emails to Mailtrap, my mail testing service, even though I had updated the .env file to use Mailgun.
I ran the usual commands:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan clear-compiled
php artisan config:cache
I restarted PHP-FPM and other services on the server, updated the Mailgun settings, reset usernames and passwords, and even disabled Cloudflare—but none of these worked.
I then started testing to see if the application was even reading the .env file, and it was. After an hour of hard-coding settings and troubleshooting, nothing was working.
Abort the mission In the end, I decided to revert back to the old server and take a day or so for debugging.
The next day
The next day, I resumed debugging, trying to figure out what I had done wrong. I couldn’t find the answer! Then I thought, "Let’s restart the server!"...
It blinking worked.
So, after all that, all I needed to do was restart the server. I’m not sure why this worked, as there was nothing that should have cached any app-specific settings like that.
Anyway, the phrase of the day is:
"Have you tried turning it off and back on again?"
I still don't know whether to be happy that I fixed the issue or upset that I didn't figure it out...