Skip to content

SQL unix socket not working #20729

Open
Open
@thelovekesh

Description

@thelovekesh

What version of Bun is running?

Bun v1.2.17 (Linux x64)

What platform is your computer?

Linux 6.8.0-62-generic x86_64 x86_64

What steps can reproduce the bug?

Setup PostgreSQL on your machine and set listen_addresses = '' in postgresql.conf so that Bun sql client does not fallback to use the tcp connection.

Now use this code snippet to test things:

import { SQL } from "bun";

{
  await using sql = new SQL({
    path: "/var/run/postgresql",
    user: "bun",
    password: "bun",
    database: "bun",
  });

  const res = await sql`SELECT count(*)::int from information_schema.columns LIMIT 1`;
  console.log(res);
}

It will give an error like:

$ bun run sql.ts 
PostgresError: Connection closed
 code: "ERR_POSTGRES_CONNECTION_CLOSED"


Bun v1.2.17 (Linux x64)

What is the expected behavior?

Client should be able to connect over unix socket if its being passed to the sql options.

What do you see instead?

PostgresError: Connection closed
 code: "ERR_POSTGRES_CONNECTION_CLOSED"


Bun v1.2.17 (Linux x64)

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsqlSomething to do with `sql` in the "bun" module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions