Skip to content

Unix sockets support on windows #737

Open
@SvanteRichter

Description

@SvanteRichter

Thanks for the library! Had an issue with what probably is an edge-case, using unix sockets on windows.

UNIX sockets are supported by postgresql on windows (I can start and connect to a database with psql without listenening on any IP), but i cannot connect with postgres.js.

If I try something like

const sql = postgres({
  path: postgresqlServer.socketDir,
  user: 'surface',
  password: 'surface'
 })
 console.log(await sql`SELECT NOW()`)

I get

  Error: connect EPERM C:\Users\surface\Downloads\db\socket
      at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)
      at cachedError (file:///C:/Users/surface/Downloads/node_modules/postgres/src/query.js:170:23)
      at new Query (file:///C:/Users/surface/Downloads/node_modules/postgres/src/query.js:36:24)
      at sql (file:///C:/Users/surface/Downloads/node_modules/postgres/src/index.js:112:11)
      at TestContext.<anonymous> (file:///C:/Users/surface/Downloads/tests/test-run.test.js:17:23) {
    errno: -4048,
    code: 'EPERM',
    syscall: 'connect',
    address: 'C:\\Users\\surface\\Downloads\\db\\socket'

But if I try with an actual psql.exe it works:

psql.exe -d 'postgres://surface:surface@surface/postgres?host=C:\Users\surface\Downloads\db\socket'

Had a similar issue with node-postgres so opened a issue there too: brianc/node-postgres#3100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions