Prerendering does not work when building Docker container
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Start
Describe the bug
When trying to build a TanStack Start project in SPA mode with Docker Vite fails to connect to the server. The build works fine outside of Docker.
3.276 [nitro] ✔ You can preview this build using bun run .output/server/index.mjs
3.277 [prerender] Prerendering pages...
3.305
3.305 ╭───────────────── [Build Info] ────────────────────╮
3.305 │ │
3.305 │ - Build Directory: .output │
3.305 │ - Date: 1/2/2026, 5:55:52 AM │
3.305 │ - Nitro Version: 3.0.1-20251230-165713-6e801e22 │
3.305 │ - Nitro Preset: bun │
3.305 │ │
3.305 ╰───────────────────────────────────────────────────╯
3.305
3.305 ℹ Spawning preview server...
3.305 ℹ bun run ./server/index.mjs
3.305
3.324 ➜ Listening on: http://localhost:46317/ (all interfaces)
3.841 [prerender] Concurrency: 10
3.842 [prerender] Crawling: /
3.855 [prerender] Prerendered 0 pages:
3.859 error: Unable to connect. Is the computer able to access the url?
3.859 path: "http://localhost:3000/",
3.859 errno: 0,
3.859 code: "ConnectionRefused"
I've also tried forcing the Nitro port to run at 3000 which ends up with the Vite prerender server failing to start instead.
Your Example Website or App
https://github.com/NormySan/tanstack-start-spa-nitro
Steps to Reproduce the Bug or Issue
- Download repository
- Build the docker image with
docker build -t tanstack-start/nitro .
Expected behavior
I expect it to be able to connect to the server and to the pre-rendering.
Screenshots or Videos
No response
Platform
- Router / Start Version: Router 1.132.0 and Start 1.132.0
- Nitro: Nightly at latest
- Runtime: Bun
- OS: Mac OS
- Bundler: Vite
- Bundler Version: 7.1.7
Additional context
Similar to the following issue:
https://github.com/TanStack/router/issues/5967#issuecomment-3704465609
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and run its docker build -t tanstack-start/nitro . command, then compare the Vite/Nitro prerender logs with the generated .output/server/index.mjs preview entry point. Done means the Docker build can start the preview server and prerender the application without the connection-refused error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, docker, typescript, vite
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100