DDEV dbserver bound only to IPv4 interface - use 127.0.0.1 instead of localhost
Is there an existing issue for this?
- [X] I have searched the existing issues
Run a Diagnostic and Paste Link Here
N/A
Current Behavior
In the DDEV Integration Plugin we got an issue, that the data source integration does not work for some linux distributions. It looks like this issue is caused by ddev ports only bound to 127.0.0.1 but not to the IPv6 interface ::1. Since the database is referenced by localhost:49354 this will resolve to ::1 in some Linux distributions. The database can not be connected by the host. Connecting by 127.0.0.1:49354 works.
Expected Behavior
I would exepect to reach the database container by localhost:49354 from the host system.
Steps To Reproduce
I was not able to reproduce this issue on Windows, please find additional information in the original issue linked below.
Anything else?
Original Issue: https://github.com/php-perfect/ddev-intellij-plugin/issues/24
There hasn't been a request for IPv6 support before, but docker support for it is pretty uneven.
It's not supported at all on Docker Desktop at this point, https://github.com/docker/for-mac/issues/1432
It can be enabled on linux, see https://docs.docker.com/config/daemon/ipv6/
However, DDEV is completely naive about it, so I wouldn't expect it to work with DDEV on Linux
For now, I recommend using 127.0.0.1 instead of "localhost".
Thanks for your feedback @rfay! As a workaround I will configure the plugin to prefer 127.0.0.1 over localhost.
Please note, that ddev describes suggests Host: localhost:49163 to connect the database from your host. As we just found out, this does not seem to work on IPv6 enabled devices which seems to be the default for some operating systems.
Also IPv6 support should be a longterm goal in my opinion.
Regarding the Docker Desktop Issue, I'm quite suprised that they do not support IPv6 but on systems using Docker Desktop this issue does not appear. Maybe it's the combination of enabled docker IPv6 support but not supported by DDEV, as everyone who had trouble with the plugin trying to connect to localhost was using native linux with native docker.
Actually, I think the problem you're seeing with the ambiguity of "localhost" is a common problem on systems that support ipv6; it's been a while but I've seen it before, and "localhost" is the worst of the problems. Browsers know how to handle multiple IPs on a name lookup and then try them, but other software may not.
I think it's reasonable, but not terribly urgent, to use "127.0.0.1" in ddev list and ddev describe.
I just went to work on this and can't find any instances where ddev list or ddev describe use localhost in their recommendations any more. Not sure if it was fixed elsewhere or what. Please let me know about remaining issues here.