Servers with Dart | Edit these docs

Dart on the Server


  1. Examples
  2. Get started
  3. Get support
  4. Libraries
  5. Learn more
  6. Hosting Dart servers

Dart is a great fit for server applications.

The Dart VM runs anywhere you can get a Linux, Windows, or Mac prompt. It has been ported to i32, x64, ARM, ARM64, and MIPS.

You can access files, UDP and TCP sockets, HTTP, WebSockets, and more with the dart:io libraries. Write a server, connect to a REST service, parse JSON, and more.

Debugging and profiling your server app is easy with Observatory. Connect to your VM with your browser, and get real-time insight into your running app.

Use Isolates for secure, concurrent apps. Spawn an isolate to run Dart functions and libraries in an isolated heap, and take advantage of multiple CPU cores.

Asynchronous code is easy to write, with the new async/await/yield language features.

RPC services are easy to create and consume, with the rpc package. You can write your RPC server in Dart, and generate client libraries for Java, C#, and more.


Build an HTTP server:

import 'dart:io';

main() async {
  var server = await HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080);
  print("Serving at ${server.address}:${server.port}");

  await for (var request in server) {
      ..headers.contentType = new ContentType("text", "plain", charset: "utf-8")
      ..write('Hello, world')

Server WebSockets:

import 'dart:io';
import 'dart:async';

handleMsg(msg) {
  print('Message received: $msg');

main() {
  runZoned(() async {
    var server = await HttpServer.bind('', 4040);
    await for (var req in server) {
      if (req.uri.path == '/ws') {
        // Upgrade a HttpRequest to a WebSocket connection.
        var socket = await WebSocketTransformer.upgrade(req);
  onError: (e) => print("An error occurred."));

Get HTTP resources:

import 'package:http/http.dart' as http;

main() async {
  var contents = await'');

Get started

Start with our tutorials. Once you’re coding, consult the API documentation.

You may want to learn about Dart’s asynchrony support. Start with Asynchrony support, a section in the language tour. If you want more, you can deep dive into Dart Language Asynchrony Support: Phase 1 and Dart Language Asynchrony Support: Phase 2.

Get support

Join our mailing list and chat with other engineers building server-side Dart apps.

Post your “how-to” questions to Stack Overflow.

And of course, we welcome bug reports.


There are lots of options for building server-side and command-line apps with Dart. Here are just some of our favorites.

Out of the box, Dart supports TLS/SSL.

dart:io provides core functionality, such as files, directories, sockets, HTTP, and lots more. Shelf is a middleware system for web servers, with a robust plugin system. Redstone is a server-side microframework for Dart. MySQL driver helps you connect to MySQL from Dart. PostgreSQL driver helps you connect to PostgreSQL from Dart. Args is a configurable parser of command-line args. Http helps you easily connect to HTTP resources.

Check for more options and libraries, including ORM, Redis, Mongo, authentication, Google APIs, and more.

Learn more

Watch this video, recorded at the Dart Developer Summit, about moving from Node.js to Dart.

Then, dive deep with our articles, examples, and other documentation.

Hosting Dart servers

You have many options. Here are a few:

In addition, Dart runs on most cloud providers, such as Amazon’s EC2, Digital Ocean, and more.