Skip to main content


Deno standard library
Go to Latest
function serveListener
import { serveListener } from "";

Constructs a server, accepts incoming connections on the given listener, and handles requests on these connections with the given handler.

import { serveListener } from "";

const listener = Deno.listen({ port: 4505 });

console.log("server listening on http://localhost:4505");

await serveListener(listener, (request) => {
  const body = `Your user-agent is:\n\n${request.headers.get(
  ) ?? "Unknown"}`;

  return new Response(body, { status: 200 });


listener: Deno.Listener

The listener to accept connections from.

handler: Handler

The handler for individual HTTP requests.

options: ServeListenerOptions

Optional serve options.