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

Fails to Connect in WSL 1 Due to TCP User Timeout (os error 92) #1214

Open
swnoh opened this issue Feb 11, 2025 · 3 comments · May be fixed by #1215
Open

Fails to Connect in WSL 1 Due to TCP User Timeout (os error 92) #1214

swnoh opened this issue Feb 11, 2025 · 3 comments · May be fixed by #1215

Comments

@swnoh
Copy link

swnoh commented Feb 11, 2025

Description:

Hello,
After upgrading Prisma from 5.19.1 to 6.3.0, I encountered an issue where Prisma could no longer connect to the database in WSL 1.

Error: P1001: Can't reach database server at `localhost:5432`

To isolate the issue, I tested it directly with the tokio-postgres library and observed the following error message:

Failed to connect to database: error connecting to server: Protocol not available (os error 92)

This issue is not limited to localhost (localhost:5432)—it also occurs when connecting to any valid PostgreSQL URL, making database connections completely unusable in WSL 1.
Upon investigation, the issue is very likely caused by the use of TCP user timeout, which may not be supported in WSL 1. However, the existing approach of setting TCP keepalive works fine.
The relevant code can be found here: connect_socket.rs#L33

Regression Details:

  • This change was introduced in Prisma 5.22.0, when tokio-postgres was upgraded from 0.7.7 to 0.7.12.
  • Before Prisma 5.22.0, database connections in WSL 1 worked as expected.

Steps to Reproduce:

  1. Use tokio-postgres in a WSL 1 environment
  2. Attempt to connect to a PostgreSQL database running on localhost:5432
  3. Observe the connection failure with os error 92

Expected Behavior:

tokio-postgres should be able to connect to the database in WSL 1, as it did in previous versions.

Environment:

  • Library: tokio-postgres
  • WSL Version: 1
  • Distro: Ubuntu 22.04.5 LTS
  • Database: PostgreSQL v16
  • Operating System: Windows 10

Thanks! Please let me know if I can provide any further details.

@sfackler
Copy link
Owner

I'd recommend migrating to WSL2 so you can run on actually-Linux instead of Windows-pretending-to-be-Linux.

@swnoh
Copy link
Author

swnoh commented Feb 11, 2025

Thanks for the quick reply! At the moment, I still need to stick with WSL 1 due to corporate policy for the Windows version. I also wanted to raise this in case there's a possible workaround or fix for WSL 1 users. Thanks again for taking the time to look into it.

@sfackler
Copy link
Owner

Oh we can just only set the timeout if it's Some. Should be an easy change.

@sfackler sfackler linked a pull request Feb 12, 2025 that will close this issue
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 a pull request may close this issue.

2 participants