Next.js Discord

Discord Forum

standalone server not working as expected compared to npm start

Unanswered
Samoyed posted this in #help-forum
Open in Discord
SamoyedOP
I have a deployment using docker compose and traefik. I've been looking at migrating my docker image to use the standalone output and server.js as opposed to npm start in my images.
Given both serve the app on :3000, I expected there would not be too much difference in how I would have to deploy them, other than the smaller image size.
When I use npm start, traefik automatically picks up the web app as a service without me having to specify a hostname or port.
However, using node server.js, traefik doesn't see the service at all, even when I manually configure the ports.
Is there a difference in how you need to deploy or expose your service when using node server.js as opposed to npm start?
For the standalone output, I'm even using the official Dockerfile specified [here](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile), like the [Deployment Section](https://nextjs.org/docs/app/building-your-application/deploying#docker-image) of the docs specifies.
Any help would be greatly appreciated.

1 Reply

SamoyedOP
I understand there's a HOSTNAME environment variable that defaults to 0.0.0.0, but I'm unable to find any information as to how that affects the deployment, as it is suggested that the app would be available at localhost:3000 within the container, but my healthcheck wget --spider http://localhost:3000/api/healthcheck doesn't function either, as if the app isn't even being served on localhost:3000