Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/cli/tsc/dts/lib.deno.ns.d.ts>Deno.ServeOptions

A modern runtime for JavaScript and TypeScript.
Go to Latest
interface Deno.ServeOptions
import { type Deno } from "https://deno.land/x/deno@v1.36.0/cli/tsc/dts/lib.deno.ns.d.ts";
const { ServeOptions } = Deno;

Options which can be set when calling Deno.serve.

Properties

optional
port: number = 8000

The port to listen on.

optional
hostname: string = "0.0.0.0"

A literal IP address or host name that can be resolved to an IP address.

Note about 0.0.0.0 While listening 0.0.0.0 works on all platforms, the browsers on Windows don't work with the address 0.0.0.0. You should show the message like server running on localhost:8080 instead of server running on 0.0.0.0:8080 if your program supports Windows.

optional
signal: AbortSignal

An AbortSignal to close the server and all connections.

optional
reusePort: boolean

Sets SO_REUSEPORT on POSIX systems.

optional
onError: (error: unknown) => Response | Promise<Response>

The handler to invoke when route handlers throw an error.

optional
onListen: (params: { hostname: string; port: number; }) => void

The callback which is called when the server starts listening.