Cover image for Deploy your Deno apps to Heroku

Deploy your Deno apps to Heroku

ms314006 profile image Clark ・2 min read

originally post: Deploy your Deno apps to Heroku

Hello, guys! I am Clark! In this post, I am going to share about how to deploy your Deno applications to Heroku!

Ok, The first we need to have a Deno application. if you didn't download Deno in your system, you can refer to this page, or if you already download Deno, you can create a Deno applications folder and create a index.ts in the folder:

import { serve } from "https://deno.land/std@0.57.0/http/server.ts";

const s = serve({ port: 8000 });

for await (const req of s) {
  req.respond({ body: "Hello World\n" });

When you finished, you can type below commend to run this Deno application:

deno run --allow-net index.ts

You can open browser and type http://localhost:8000/ into url:

Alt Text

Next, if we deploy a application to Heroku, Heroku will give me a port, we need to use this port instead of the 8080 we set. So we will use flags to help us parse port from args when our Deno applications running with Heroku.

For that, we need to edit our index.ts:

import { serve } from "https://deno.land/std@0.57.0/http/server.ts";
import { parse } from 'https://deno.land/std/flags/mod.ts';

const { args } = Deno;
const DEFAULT_PORT = 8000;
const argPort = parse(args).port;

const s = serve({ port: argPort ? Number(argPort) : DEFAULT_PORT });

for await (const req of s) {
  req.respond({ body: "Hello World\n" });

So far, look nice! Than, we need create Procfile file, Heroku will run commends from Procfile file, when we deployed our Deno applications:

web: deno run --allow-net=:${PORT} index.ts --port=${PORT}

Last, we go to website of Heroku, create a new application and switch to Settings page of the application:

Alt Text

And we pay attention to Buildpacks:

Alt Text

Before, we usually choose a Buildpack to run our commend, maybe nodejs, php, ruby or go. But now we need to set a environment to run Deno, and the most terrible thing is...Heroku have no Deno let us choose:

Alt Text

Don't worry, please enter below Buildpack URL to input box:


When we finished above steps, we just need to deploy our Deno applications to Heroku like as other applications. If you never deploy any applications to Heroku, you can refer to this part, but you don't need to type heroku create because you already did.

If you guys have any questions, please comment below and let me know. thank for you read!


  1. Deploy your first Deno Web App to Heroku

Posted on by:

ms314006 profile



I love share knowledge and writing blog posts(about frontend skill), like coding enjoy life.


markdown guide

Thanks for this. For some reason I can't make it work. I still get permission errors despite having it in my Procfile.

Here's the error:

2020-08-02T13:13:01.283479+00:00 app[web.1]: Check file:///app/index.ts
2020-08-02T13:13:06.139127+00:00 app[web.1]: INFO downloading deno plugin "deno_mongo" from "https://github.com/manyuanrong/deno_mongo/releases/download/v0.9.1/libdeno_mongo.so"
2020-08-02T13:13:06.145764+00:00 app[web.1]: error: Uncaught PermissionDenied: network access to "https://github.com/manyuanrong/deno_mongo/releases/download/v0.9.1/libdeno_mongo.so", run again with the --allow-net flag


web: deno run --allow-net=:${PORT} --allow-read --allow-write --allow-plugin --unstable -c tsconfig.json index.ts --port=${PORT}

any idea?


You missed --allow-net flag, maybe you can edit the content of Procfile to following:

web: deno run --allow-net=:${PORT} --allow-read --allow-write --allow-plugin --allow-net --unstable -c tsconfig.json index.ts --port=${PORT}


Doing --allow-net instead of --allow-net=:${PORT} works.


Sorry! It is my fault, I missed that you already had --allow-net!

But I think maybe you can change the sequence to:

web: deno run --allow-net=:${PORT} --allow-read --allow-write --allow-plugin --unstable -c index.ts tsconfig.json --port=${PORT}

You can try again. I have seen some problems occur in sequence.

tsconfig.json should appear after -c though.


Hi, all of the above worked fine. but when i try to run my app on local with 'heroku local' it throws an error "Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum".
Any idea why?
It is up and running on local when i deno run my app.


Hello, can I see anything of your code? maybe Github or others way.

And your app is running perfectly but it throw error message?


Thank you for your reply. I was able to deploy it properly. The problem was with websockets.
Great article 👍