Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function getAvailablePort
import { getAvailablePort } from "https://deno.land/std@0.217.0/net/get_available_port.ts";

Returns an available network port.

Examples

Example 1

import { getAvailablePort } from "https://deno.land/std@0.217.0/net/get_available_port.ts";

const port = getAvailablePort();
Deno.serve({ port }, () => new Response("Hello, world!"));

Returns

number