Repository navigation
Conversation
Next.js standalone listens on process.env.HOSTNAME, which Docker sets to the container ID. A Compose service with a domain is attached to both dokploy-network and the default network, so the ID resolves to two addresses and the app binds only one. Document setting HOSTNAME=0.0.0.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs Dokploy/dokploy#5074
Adds the docs note that issue asks for, under Troubleshooting > Domains & Traefik > Getting "Bad Gateway Error", next to the existing Vite example.
A Next.js app built with
output: "standalone"listens onprocess.env.HOSTNAME || '0.0.0.0'(packages/next/src/build/utils.ts), and Docker setsHOSTNAMEto the container ID. For a Compose service with a domain,addDokployNetworkToServiceattaches bothdokploy-networkanddefault, so the ID has two entries in/etc/hostsand the app binds only one of them. Traefik dials thedokploy-networkaddress (traefik.docker.network=dokploy-network), so deploys that bind the default network address return Bad Gateway until the next redeploy.Reproduction
Docker 28.5, Compose 2.40. A Compose service on
[dokploy-network, default], the shape Dokploy generates, running a server that picks its host the same way as Next.js standalone, requested from a separate container ondokploy-networkvia the service'sdokploy-networkIP, as Traefik does:Both fixes in the note were checked:
ENV HOSTNAME="0.0.0.0"in the image andenvironment: HOSTNAME=0.0.0.0in Compose each override Docker's default, and the container's hostname itself is unchanged. The Dockerfile form matches the official Next.js Docker example.