"unexpectedly closed the connection" yet app services is healthy?

I have the following fastify app which is reporting back as healthy:

However, when I utilise flyctl open or navigate to either the hostname or IP address, I am seeing a " vega.fly.dev unexpectedly closed the connection." message on https?

My Dockerfile is as follows:

# FROM latest node image https://hub.docker.com/_/node/
FROM node:latest

# Create and set app directory
RUN mkdir -p /usr/src/

WORKDIR /usr/src/app/

# Prefer not to run as root.
USER node

# Give ownership to the node user:
USER root

RUN chown -R node /usr/src/app/

RUN corepack enable

USER node

COPY --chown=node ./ /usr/src/app/

RUN yarn install

# Build for production
RUN yarn build

# Expose internal port for production
EXPOSE 8981

# Server for production
ENTRYPOINT [ "yarn" ]
CMD ["serve"]

And my fly.toml is as follows:

# fly.toml file generated for vega on 2022-06-13T16:52:46+01:00

app = "vega"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8981
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

What extra do I need to do here to get this working?

Nothing stands out as being wrong in those …

In my experience with Node/Fastify you need to be listening on IPv6, rather than IPv4. That isn’t the default. So for example a mini Fastify app (notice the listen line at the bottom):

'use strict'

import Fastify from 'fastify'

const fastify = Fastify({
    logger: true
})

fastify.get('/', async (request, reply) => {
    return { hello: 'world' }
})

const start = async () => {
    try {
        fastify.log.info('Starting web server ...');
        await fastify.listen(8080, '::')
    } catch (err) {
        fastify.log.error(err)
        process.exit(1)
    }
}
start()

That listen line listens on :: Give that a try. May be as simple as changing that equivalent in your js code.