A Node.js project demonstrating HTTP servers over Unix domain sockets and Windows named pipes. This example is designed to test Postman's Unix domain socket URL support.
On Unix-like systems (macOS, Linux), a Unix domain socket (UDS) is a special kind of file that lets processes on the same machine communicate using the socket API. Instead of using TCP/IP with localhost and a port number, you use a filesystem path like /tmp/http-socket.sock.
Windows Note: Windows uses Named Pipes (\\.\pipe\myserver) to provide similar functionality.
To connect to a Unix domain socket in Postman, use this syntax:
protocol://unix:<socket-path>:<resource-path>
Where:
protocol(optional):httporhttps(defaults tohttpif omitted)socket-path: absolute path to the socket fileresource-path(optional): path to a specific resource (e.g.,/hello)
macOS/Linux:
http://unix:/tmp/http-socket.sock:/hello
unix:/tmp/http-socket.sock:/hello (shorthand)
Windows (Named Pipes):
http://unix:\\\\.\\pipe\\myserver:/hello (backward slash)
http://unix://./pipe/myserver:/hello (forward slash)
npm installnpm run serverThis starts an HTTP server listening on /tmp/http-socket-<machine-id>.sock (where <machine-id> is a randomly generated hex string) with the following endpoints:
GET /- Server information and available endpointsGET /hello- Simple hello world responsePOST /echo- Echo back the request bodyGET /headers- Returns request headersGET /status/201- Returns 201 status codeGET /status/404- Returns 404 status code
In a separate terminal, run the test client. Make sure to use the same MACHINE_ID that the server displays:
MACHINE_ID=<machine-id-from-server> npm run clientFor example, if the server shows Machine ID: a1b2c3d4e5f6g7h8, run:
MACHINE_ID=a1b2c3d4e5f6g7h8 npm run clientThis will make test requests to all available endpoints.
Tip: You can also set a custom machine ID when starting the server:
MACHINE_ID=my-custom-id npm run serverWith the server running, copy the socket path from the server output (which includes the machine ID) and use it in Postman. For example, if the server shows /tmp/http-socket-a1b2c3d4e5f6g7h8.sock, use these URLs:
unix:/tmp/http-socket-a1b2c3d4e5f6g7h8.sock:/
unix:/tmp/http-socket-a1b2c3d4e5f6g7h8.sock:/hello
unix:/tmp/http-socket-a1b2c3d4e5f6g7h8.sock:/headers
unix:/tmp/http-socket-a1b2c3d4e5f6g7h8.sock:/echo (POST request)
The server output will display the exact Postman URLs to use.
For Windows systems, use the named pipe server:
npm run server:windowsThen test in Postman with:
http://unix://./pipe/myserver:/hello
npm run server- Start Unix domain socket server (macOS/Linux)npm run client- Run test clientnpm run server:windows- Start named pipe server (Windows only)npm start- Run the default index.jsnpm run dev- Run in watch mode
- Node.js >= 18.0.0
server.js- HTTP server using Unix domain socket (macOS/Linux)client.js- Test client for making requestsserver-windows.js- HTTP server using Windows Named Pipesindex.js- Main entry point (starter template)
MIT