Skip to content
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

Db connection : "localhost" and "::1" confusion #4253

Closed
TeoConan opened this issue Sep 23, 2023 · 2 comments
Closed

Db connection : "localhost" and "::1" confusion #4253

TeoConan opened this issue Sep 23, 2023 · 2 comments

Comments

@TeoConan
Copy link

Package version

11.3.1

Node.js and npm version

v18.16.0, 9.5.1

Sample Code (to reproduce the issue)

In .env, MYSQL_HOST=localhost

BONUS (a sample repo to reproduce the issue)

I don't know if it's juste me, but if you create an Adonis project, setup a MySQL connection and try, for example, to run a migration with this line in your .env file :

MYSQL_HOST=localhost

You'll receive :

$ node ace migration:run
Error: connect ECONNREFUSED ::1:3306

So I tried to do this to verify what's happening on my local mysql :

mysql -h localhost -uroot -p -D lucid # work
mysql -h ::1 -uroot -p -D lucid # doesn't work

You can correct this very easily by set your .env var MYSQL_HOST by 127.0.0.1

@RomainLanz
Copy link
Member

Hey @TeoConan! 👋🏻

That's a change in how Node.js resolves localhost. Now it returns IP addresses in the order they are returned from the name resolver/DNS. nodejs/node#39987

Maybe we should change the default value in our .env file to 127.0.0.1 to avoid any issue related to this.
Any feedback on this @targos?

@targos
Copy link
Member

targos commented Sep 25, 2023

+1 to use 127.0.0.1

kingIwan added a commit to kingIwan/Full-stack-res that referenced this issue Nov 15, 2024
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

No branches or pull requests

3 participants