vitejs/vite · critical · Error
HTTP server not available
Error message
HTTP server not available
What it means
In the CLI serve action (cli.ts:233-234), after createServer() returns, Vite checks server.httpServer. If it is null/undefined (the underlying Node HTTP server was not created), it throws 'HTTP server not available'. This happens when server configuration disables or prevents the HTTP server from being instantiated.
Source
Thrown at packages/vite/src/node/cli.ts:234
const { createServer } = await import('./server')
try {
const server = await createServer({
root,
base: options.base,
mode: options.mode,
configFile: options.config,
configLoader: options.configLoader,
logLevel: options.logLevel,
clearScreen: options.clearScreen,
server: cleanGlobalCLIOptions(options),
forceOptimizeDeps: options.force,
experimental: {
bundledDev: options.experimentalBundle,
},
})
if (!server.httpServer) {
throw new Error('HTTP server not available')
}
await server.listen()
const info = server.config.logger.info
const modeString =
options.mode && options.mode !== 'development'
? ` ${colors.bgGreen(` ${colors.bold(options.mode)} `)}`
: ''
const viteStartTime = global.__vite_start_time ?? false
const startupDurationString = viteStartTime
? colors.dim(
`ready in ${colors.reset(
colors.bold(Math.ceil(performance.now() - viteStartTime)),
)} ms`,
)
: ''View on GitHub (pinned to 89620f09af)
Solutions
- Avoid server.middlewareMode (or { server: { middlewareMode: true } }) when launching via the `vite` CLI, since middleware mode has no httpServer.
- If you need a custom server, use the JS API (createServer + server.listen) and handle the no-httpServer case yourself rather than the CLI.
- Remove any plugin/config that strips or replaces the httpServer.
Example fix
// before
export default { server: { middlewareMode: true } } // then run `vite`
// after
export default {} // let the CLI create a normal HTTP server
// (or use the JS API: const server = await createServer({ server: { middlewareMode: true } })) Defensive patterns
Strategy: validation
Validate before calling
const server = await createServer(config)
if (!server.httpServer) {
throw new Error('Dev server has no httpServer — avoid middlewareMode via the CLI')
} Type guard
function hasHttpServer(server: ViteDevServer): boolean {
return server.httpServer != null
} Prevention
- Don't enable server.middlewareMode when launching through the `vite` CLI.
- Use the JS API (createServer) directly when you need middleware mode.
- Avoid plugins that replace the underlying HTTP server.
When it happens
Trigger: Running `vite` (serve/dev) with a config that sets server options incompatible with creating an HTTP server, or a middleware/plugin that returns a server without an httpServer — e.g. misusing server.middlewareMode or a custom server factory.
Common situations: Configuring the dev server in middleware mode (where no httpServer is attached) but still running via the CLI `vite` command; a plugin that overrides server creation; port/host conflicts causing a non-standard server object.
Related errors
- multiple output options are not supported in dev mode
- Environment "${name}" is not defined in the config.
- There is already a server associated with the config.
- Config was resolved for a "build", expected a "serve" comman
- Cannot print server URLs in middleware mode.
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/d4dc4e8af67dd229.json.
Report an issue: GitHub.