Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reloading .env variables without restarting server (Laravel 5, shared hosting)

My Laravel 5 has run OK until the database was configured, then found this error:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known 

Doing some research it seems that I configured MySQL access too late, so I should restart the server in order to get the correct environment variables. Well, I'm using Dreamhost's shared server and I just can't do that.

How should I fix this issue?

Thanks

like image 353
godsaway Avatar asked Sep 06 '15 11:09

godsaway


2 Answers

If you have run php artisan config:cache on your server, then your Laravel app could cache outdated config settings that you've put in the .env file.

Run php artisan config:clear to fix that.

like image 153
Harry Avatar answered Sep 22 '22 11:09

Harry


I know this is old, but for local dev, this is what got things back to a production .env file:

rm bootstrap/cache/config.php 

then

php artisan config:cache php artisan config:clear php artisan cache:clear 
like image 31
Janiis Avatar answered Sep 25 '22 11:09

Janiis