diff --git a/docs/advanced-features/custom-server.md b/docs/advanced-features/custom-server.md index 89ce91bfb235e..9a2b05d950264 100644 --- a/docs/advanced-features/custom-server.md +++ b/docs/advanced-features/custom-server.md @@ -53,10 +53,14 @@ app.prepare().then(() => { res.statusCode = 500 res.end('internal server error') } - }).listen(port, (err) => { - if (err) throw err - console.log(`> Ready on http://${hostname}:${port}`) }) + .once('error', (err) => { + console.error(err) + process.exit(1) + }) + .listen(port, () => { + console.log(`> Ready on http://${hostname}:${port}`) + }) }) ```