Skip to content
Tim Hårek's logo

How to self-host Deno Fresh

2 minutes read

I self-host my own website built with Deno Fresh on my own VPS using systemd and Caddy. The reason behind this is that I don't want to rely on a third-party service that I don't have control over and I don't want to use GitHub Actions when I can use my sourceforge of choice, which is SourceHut.


You need the following to be installed:

  1. systemd
    • You can check by running systemctl --version.
  2. Caddy (useful to have some beginner knowledge on how to use it)
  3. Deno
    • Installation guide
    • or run: curl -fsSL | sudo DENO_INSTALL=/usr/local sh


1. Set up a systemd service

We want to use systemd so that we have a reliable way of running Deno in a way that don't require our input. Therefore we need to create a new service, and that can look like the following:

Description=<name-of-service> (Deno Fresh)

ExecStart="PORT=6969 deno run --no-lock -A <path-to-project>/main.ts"


This service-configuration lets us access the network attached to the server, has a environment file attached, is being run from a specific directory and restarts on failure.

Remember to replace:

  • <name-of-service>
  • <user>
  • <path-to-project>

Then create the configuration file in /etc/systemd/system/<name-of-service>.service.

You can now enable the service with:

systemctl enable <name-of-service>.service

Note that you don't have to prefix the ExecStart with PORT=6969, you can also provide that in the environment file in your project.

2. Configure Caddy

In your Caddyfile you can add the following:

<domain-with-tld> {
    reverse_proxy localhost:6969

This makes a reverse-proxy on the server, ie. why localhost is there, and points the proxy to the port 6969.

Replace <domain-with-tld> with your actual domain, like

Then run caddy reload to reload your Caddyfile with your latest changes.

3. Start your project

systemctl start <name-of-service>.service

Then you can check if your Deno Fresh project is running with:

systemctl status <name-of-service>.service

And then you can check if your web-project is available on the domain you set up in your Caddyfile.


Now you should be able to run a Deno Fresh on your own server with systemd, Caddy and Deno installed.