---
title: Support for Node.js DNS, Net, and Timer APIs in Workers
description: Node.js APIs from the node:dns, node:net, and node:timers modules are now available when using nodejs_compat.
image: https://developers.cloudflare.com/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://developers.cloudflare.com/changelog/rss/index.xml) [ View RSS feeds ](https://developers.cloudflare.com/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://developers.cloudflare.com/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://developers.cloudflare.com/changelog/) 

## Support for Node.js DNS, Net, and Timer APIs in Workers

Jan 28, 2025 

[ Workers ](https://developers.cloudflare.com/workers/) 

When using a Worker with the [nodejs\_compat](https://developers.cloudflare.com/workers/runtime-apis/nodejs/) compatibility flag enabled, you can now use the following Node.js APIs:

* [node:net](https://developers.cloudflare.com/workers/runtime-apis/nodejs/net/)
* [node:dns](https://developers.cloudflare.com/workers/runtime-apis/nodejs/dns/)
* [node:timers](https://developers.cloudflare.com/workers/runtime-apis/nodejs/timers/)

#### node:net

You can use [node:net ↗](https://nodejs.org/api/net.html) to create a direct connection to servers via a TCP sockets with [net.Socket ↗](https://nodejs.org/api/net.html#class-netsocket).

* [  JavaScript ](#tab-panel-2791)
* [  TypeScript ](#tab-panel-2792)

index.js

```
import net from "node:net";
const exampleIP = "127.0.0.1";
export default {  async fetch(req) {    const socket = new net.Socket();    socket.connect(4000, exampleIP, function () {      console.log("Connected");    });
    socket.write("Hello, Server!");    socket.end();
    return new Response("Wrote to server", { status: 200 });  },};
```

index.ts

```
import net from "node:net";
const exampleIP = "127.0.0.1";
export default {  async fetch(req): Promise<Response> {    const socket = new net.Socket();    socket.connect(4000, exampleIP, function () {      console.log("Connected");    });
    socket.write("Hello, Server!");    socket.end();
    return new Response("Wrote to server", { status: 200 });  },} satisfies ExportedHandler;
```

Additionally, you can now use other APIs including [net.BlockList ↗](https://nodejs.org/api/net.html#class-netblocklist) and [net.SocketAddress ↗](https://nodejs.org/api/net.html#class-netsocketaddress).

Note that [net.Server ↗](https://nodejs.org/api/net.html#class-netserver) is not supported.

#### node:dns

You can use [node:dns ↗](https://nodejs.org/api/dns.html) for name resolution via [DNS over HTTPS](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/) using [Cloudflare DNS ↗](https://www.cloudflare.com/application-services/products/dns/) at 1.1.1.1.

* [  JavaScript ](#tab-panel-2787)
* [  TypeScript ](#tab-panel-2788)

index.js

```
import dns from "node:dns";
let response = await dns.promises.resolve4("cloudflare.com", "NS");
```

index.ts

```
import dns from 'node:dns';
let response = await dns.promises.resolve4('cloudflare.com', 'NS');
```

All `node:dns` functions are available, except `lookup`, `lookupService`, and `resolve` which throw "Not implemented" errors when called.

#### node:timers

You can use [node:timers ↗](https://nodejs.org/api/timers.html) to schedule functions to be called at some future period of time.

This includes [setTimeout ↗](https://nodejs.org/api/timers.html#settimeoutcallback-delay-args) for calling a function after a delay, [setInterval ↗](https://nodejs.org/api/timers.html#setintervalcallback-delay-args) for calling a function repeatedly, and [setImmediate ↗](https://nodejs.org/api/timers.html#setimmediatecallback-args) for calling a function in the next iteration of the event loop.

* [  JavaScript ](#tab-panel-2789)
* [  TypeScript ](#tab-panel-2790)

index.js

```
import timers from "node:timers";
console.log("first");timers.setTimeout(() => {  console.log("last");}, 10);
timers.setTimeout(() => {  console.log("next");});
```

index.ts

```
import timers from "node:timers";
console.log("first");timers.setTimeout(() => {  console.log("last");}, 10);
timers.setTimeout(() => {  console.log("next");});
```

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://developers.cloudflare.com/changelog/post/2025-01-28-nodejs-compat-improvements/#page","headline":"Support for Node.js DNS, Net, and Timer APIs in Workers · Changelog","description":"Node.js APIs from the node:dns, node:net, and node:timers modules are now available when using nodejs\\_compat.","url":"https://developers.cloudflare.com/changelog/post/2025-01-28-nodejs-compat-improvements/","inLanguage":"en","image":"https://developers.cloudflare.com/changelog-preview.png","dateModified":"2025-01-28","datePublished":"2025-01-28","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
