Route the driver through a Docker-hosted proxy on port 5433.
Local Postgres development
Neon · Pipe
wsProxy configures the WebSocket proxy endpoint used by Neon’s serverless driver. A callback can transform the target database host into a proxy URL, which is useful for local Postgres and host-specific routing.
wsProxy customizes the WebSocket-proxy address used by Neon’s serverless driver. It may be a host string for one proxy or a function that receives the database host and returns the proxy URL, enabling local Postgres or host-dependent routing.
neonConfig.wsProxy = string | ((host: string) => string)| Name | Type | Description |
|---|---|---|
host | string | A database host passed to the callback so it can construct the WebSocket proxy URL. |
A WebSocket proxy URL string when wsProxy is configured as a callback.
import { neonConfig } from '@neondatabase/serverless';
neonConfig.wsProxy = (host) => `${host}:5433/v1`;
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;Routes the serverless driver through a local WebSocket proxy on port 5433 using the proxy's /v1 path.
Local Postgres development
Multiple proxy endpoints
Non-Neon PostgreSQL access
wsProxy tells the Neon serverless driver which WebSocket proxy to use. It can be a fixed proxy host or a function that derives a proxy URL from the database host.
Follow-up: How would you support different proxy routes by host? Use a function and return a different URL based on the received host, such as adding a port and version path only for local hosts.
For a local Postgres setup, the proxy can be addressed by returning the database host with port 5433 and the /v1 path. The driver then sends its WebSocket traffic through that proxy.
Follow-up: What else may need changing locally? Turn off secure WebSockets and the pipeline TLS and connect options when the local proxy configuration requires it.
The function form receives the target host and returns the proxy endpoint, so routing can vary by destination. This supports setups with distinct proxy addresses or paths rather than one global endpoint.
Follow-up: Why is host-based routing useful? It allows local and remote database hosts to use different proxy URLs while sharing the same driver configuration.
neonConfig.useSecureWebSocketneonConfig.pipelineTLSneonConfig.pipelineConnect@neondatabase/serverless