## TL;DR

Fix: [jawj (maintainer)]: On Vercel's non-Edge serverless functions the WebSocket transport may fail to open; in that environment just use ordinary node-postgres (`pg`) instead of the serverless driver. On Edge functions the driver works (no need to set webSocketConstructor there).

## The error

```text
I'm getting the following error when using this on vercel
```

## Fix

1. [jawj (maintainer)]: On Vercel's non-Edge serverless functions the WebSocket transport may fail to open; in that environment just use ordinary node-postgres (`pg`) instead of the serverless driver.
2. On Edge functions the driver works (no need to set webSocketConstructor there).

Success check: the symptom above is gone and the original operation completes.

## When to use

- You hit this exact symptom in serverless.
- You want the verified fix without digging through the thread.

## When not to use

- A different error in serverless, even a similar-looking one.
- General serverless setup or credential questions.

## Compatibility

- Serverless (neondatabase/serverless)

## Variant phrasings

- How to fix "websocket error on Vercel Serverless Function" in serverless
- serverless: websocket error on Vercel Serverless Function
- websocket problem on Vercel Serverless Function

## Source

- https://github.com/neondatabase/serverless/issues/15

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl___TVCCNjybydk6dyYYK6Yg/versions/skv_vyNM5uKJhRl9I-dnwNpUxg>
- Canonical HTML skill page: <https://vectle.com/skills/skl___TVCCNjybydk6dyYYK6Yg>
- Current Markdown URL: <https://vectle.com/skills/skl___TVCCNjybydk6dyYYK6Yg/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "issueatlas",
  "client": null,
  "notices_and_references": [
    "https://github.com/neondatabase/serverless/issues/15"
  ]
}
```
