Skip to content

.env.example - Changed localhost to 127.0.0.1 #3641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged

.env.example - Changed localhost to 127.0.0.1 #3641

merged 1 commit into from
Jan 29, 2016

Conversation

jspringe
Copy link
Contributor

This change was made for those developing on Windows and noticed ridiculous response times (1 second) even locally. Windows performs a DNS lookup for 'localhost' which always takes 1 second. I thought I would save the few Windows people (like myself) some time with troubleshooting slow installs of redis (this is where I first noticed it).

http://stackoverflow.com/questions/14076403/redis-connection-slow-from-php

@fideloper
Copy link
Contributor

I believe the root cause of this is that windows will default to trying the IPv6 network first (if it's enabled). When it fails to connect, it then goes to the IPv4 network, which is actually in use by redis/mysql/sqlserver/etc.

(Actually reading the linked SO article, they basically say that).

Knowing that fact, I don't have a strong opinion on this one way or another (not that you care, this is just to say that I'm doing a little more than "+1", based on my experience with this issue on Windows).

I'm thinking 127.0.0.1 will just about always be safe to use (vs localhost) for Linux people, until IPv6 finally is the default used over IPv4 (no clue how many years in the future that will be).

@jspringe jspringe changed the title Changed localhost to 127.0.0.1 .env.example - Changed localhost to 127.0.0.1 Jan 28, 2016
@jspringe
Copy link
Contributor Author

I honestly don't have a strong opinion about it either. I figured I'd just throw it out there to see if it would stick. At the very least this may one day show up in google for some other poor sap having similar issues.

@lucasmichot
Copy link
Contributor

👍 too

@TommyC81
Copy link
Contributor

Been there, done that. Sensible default that will avoid some frustration. +1

taylorotwell added a commit that referenced this pull request Jan 29, 2016
.env.example - Changed localhost to 127.0.0.1
@taylorotwell taylorotwell merged commit ce7c1fe into laravel:master Jan 29, 2016
@jspringe jspringe deleted the fix-envexample branch January 29, 2016 14:40
@nhowell
Copy link

nhowell commented Jan 29, 2016

Please take into consideration that MySQL on Unix will use TCP/IP instead of a socket due to this change.

@userscapechris
Copy link

That's interesting, could affect default settings on Redhat/CentOS servers
with SELinux enabled. Would need to test if default is to only allow unix
socket connection instead of allowing tcp socket connection.

On Fri, Jan 29, 2016 at 9:17 AM, Nick Howell notifications@github.com
wrote:

Please take into consideration that MySQL on Unix will use TCP/IP instead
of a socket due to this change.


Reply to this email directly or view it on GitHub
#3641 (comment).

@jspringe
Copy link
Contributor Author

I guess it's a measurement of the lesser of 2 evils. On one hand *nix has much more documentation and support than Windows when it comes to things like Redis. On the other *nix has a much larger user base.

@vlakoff
Copy link
Contributor

vlakoff commented Feb 7, 2016

@nhowell @userscapechris It would be nice of you to share here if you find out any negative effect caused by this change.

dongyukang pushed a commit to dongyukang/laravel that referenced this pull request Dec 2, 2016
In laravel#3641 was decided to use `127.0.0.1` instead of `localhost` to avoid DNS lookups

This change is to maintain consistency between `.env` and `database.php`
LukeTowers added a commit to wintercms/winter that referenced this pull request May 15, 2021
This reverts octobercms/october@1ec2b69 (bringing back octobercms/october@6c5a83d) as it is more important for the default configuration to be in a working state for most environments than to optimize for performance for some environments. Having the default be `localhost` has caused issues for a large number of people (see octobercms/october#3411, #157, and probably many more). 

Additionally, this has been the default in Laravel since 5.2 (laravel/laravel#3641) & 5.3 (laravel/laravel@fd42e10).
fly0305 pushed a commit to fly0305/Lumen-Framework that referenced this pull request Aug 17, 2022
In laravel/laravel#3641 was decided to use `127.0.0.1` instead of `localhost` to avoid DNS lookups.

This maintain consistency between Lumen and Laravel `.env` files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants