Using supervisord to manage multiple processes in an app

Hey, I am trying to launch an app that has 3 separate processes:

  1. Front-end (Vite React)
  2. Back-end (ExpressJS)
  3. Database (Pocketbase)

I have made a working dockerfile that sets everything up correctly and manages these processes using supervisord. I understand that I need 3 different ports (I use 3000 for front-end, 3001 for back-end and 8090 for pocketbase). My initial efforts failed so I decided to take it one step at a time. First I successfully launched the front-end using this fly.toml setup:

  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

Now when I visit https://<app_name> I get the visuals. Next I tried to launch my pocketbase database. I have added this code to fly.toml:

  internal_port = 8090
  protocol = "tcp"
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
    handlers = ["http", "tls"]
    port = 8090

I launch the database with supervisord using the following line of code:

command=/app/pb/pocketbase serve --https=

Which I assume launches the database on the same app, but port 8090. So in my front-end code I use this to get the database object for later use:

import PocketBase from "pocketbase";

const pb = new PocketBase(`https://<app_name>`);

export default pb;

However, when I use this, it gives me an error saying that “requested resource at https://<app_name> does not exist”.
Am I doing something wrong with this set-up? Does the database not launch properly or am I messing up with the ports? I have read about using using [processes] in fly.toml to define different processes for different VMs, however, this will probably be more expensive, I would love to do this on a single VM.
Any help will be much appreciated, thanks!


You are correct in that using supervisord would indeed keep all three on the same VM, reducing cost. So you’d just need to get them to talk to each other.

My guess would be the URL you are using in Pocketbase needs modifying to use the internal, private network. The hostname is normally used from outside Fly (such as your frontend React, running in a browser).

(That assumes the request goes client (React) → Express → Pocketbase. Since some databases are exposed directly to the frontend client)

If so, it sounds kind of similar to the approach I set up while back when I was messing with a web/api (in that case, it was Fastify, but the principle seems much the same). Take a look at:

… and scroll down. Notice to get it working I used:

const results = await fetch('http://fastify-api.internal:8080/api')

… so that URL is the app name, using the private internal network, on port 8080. You’d likely need something similar to connect to your database by using a URL. Note don’t copy the fly.toml directly from that thread since back then it was using V1, and Fly have since moved to V2 (machines). So their syntax is probably different.

It’s also possible you need to have the database listen on IPv6 (::), rather than IPv4 ( Since Fly’s internal network uses IPv6. As you say, take it one step at a time :thinking:

1 Like

Have you checked your logs? It is possible that pocketable was launched but failed. You didn’t mention a volume… be sure to put the database on a volume so it will survive a restart/redeploy. See step 4 in

1 Like