rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.92k stars 281 forks source link

Connection from host to Postgres container fails with JDBC #6907

Open tac-adam-brusselback opened 4 months ago

tac-adam-brusselback commented 4 months ago

Actual Behavior

I am able to connect to the deployed Postgres database just fine from either within another container, or from the host machine while using a tool like psql or pgadmin4 (sqlalchemy), but all attempts to connect with a jdbc based application (dbeaver, custom application) will fail due to a Connection Refused exception.

Steps to Reproduce

Using the bitnami docker image docker.io/bitnami/postgresql:15.1.0-debian-11-r19, use helm to deploy Postgres.

Apply port forwarding using the Rancher Desktop UI.

Attempt to connect to the database using a jdbc based tool (should fail). Attempt to connect using any other tool like psql, or pgadmin (should succeed).

Result

org.postgresql.util.PSQLException: Connection to 127.0.0.1:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Expected Behavior

A successful connection.

Additional Information

This exact setup has been working for a year+ before it broke after an update to Rancher Desktop a few months ago. I don't know the exact version it broke on.

Rancher Desktop Version

1.13.1

Rancher Desktop K8s Version

1.30.0

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 11 Pro 23H2

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

We use Wireguard for specific subnets, but this issue persists without that installed. We also have Covalence Agent installed.

Nino-K commented 4 months ago

@tac-adam-brusselback are you using wsl integration or is any part of your setup running in another distro?

tac-adam-brusselback commented 4 months ago

No, not using WSL integration, networking tunnel, or any WSL proxy configuration.

Don't believe any part of the setup is running in another distro. Just a Windows host, and attempting to connect to a development containerized database with our application.

dcardozo commented 4 months ago

@tac-adam-brusselback I wonder if this is another instance of what I described in discussion #6926.

A workaround worth trying is removing the port forwarding configuration from the Rancher Desktop UI and doing this instead from the command line:

kubectl port-forward services/{your postgres service name} 5432:5432
John-Caba commented 4 months ago

This worked. Can this please be resolved in the next update?