-
Notifications
You must be signed in to change notification settings - Fork 331
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
Setting postgres listen_addresses
to *
also sets $PGHOST
to *
#1253
Comments
@Alexnortung, so is |
@sandydoo I did some research upon this and here are my findings:
Yes, I think, this scenario can be used in local development. Checkout the
Setting it to cc @Alexnortung |
in #1298 I am setting the value of |
I opened this issue because I had trouble with a client trying to connect to the address given by In regards to setting |
@Alexnortung Can you tell the steps to reproduce the client not connecting. I tried various command but for some reason PG always connected me to the database successfully. Right now, I am treating the documentation and logic as the source of truth. |
Oh, I was using a third party client. |
So yeah, using * as a PGHOST value is both valid and practical since it resolves to localhost, and when used as a listen_address, the server will be listening on localhost, this behavior just works. The bug is apparently with pg_client not accepting the * and transforming it to localhost like the libpq api does. That all said, the two things are not the same semantically and forcing on to be the same value as the other, while convenient as functional most of the time (especially if your environment only cares about localhost), is inflexible. I'd suggest adding an optional pghost configuration setting that, when absent, preserves the current behavior. If present, and empty, results in PGHOST being unset. Otherwise the final value of PGHOST becomes whatever that setting specifies. Then the user can set the two values independently if needed. David J. |
Actually, most likely the OS libraries are deviating on whether * as a host name is transformed to localhost or not. Apparently macOS fails this while Linux is fine. |
Describe the bug
Hello, I was having some issues with a program that tried to connect to postgres in my devenv project.
I have set
listen_addresses
to*
so that it could be used without needing to use the socket file.However, this meant that devenv set the
$PGHOST
environment variable to*
, which made the program I was using try to connect to*
instead of0.0.0.0
for example.This was really confusing, since I did not know that devenv was setting the
$PGHOST
and it was even more confusing that it would set it to something that was invalid.To reproduce
Expected behavior
I would expect devenv either to not set the env variable at all or set it to something that was still valid, like
0.0.0.0
.Version
Using flakes
devenv: 1.0.5
The text was updated successfully, but these errors were encountered: