From 8d2c6cc0735be289a2786fc048762f08b84d7fd2 Mon Sep 17 00:00:00 2001 From: Anuj Kapoor Date: Fri, 10 Dec 2021 20:02:32 +0530 Subject: [PATCH] :zap: Added fallback when port in use (#2524) * Added fallback when port in use * :zap: Minor Fixes --- packages/cli/src/Server.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index c636db56f0..2a647abaa7 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -2905,6 +2905,15 @@ export async function start(): Promise { InternalHooksManager.getInstance().onServerStarted(diagnosticInfo, workflow?.createdAt), ); }); + + server.on('error', (error: Error & { code: string }) => { + if (error.code === 'EADDRINUSE') { + console.log( + `n8n's port ${PORT} is already in use. Do you have another instance of n8n running already?`, + ); + process.exit(1); + } + }); } async function getExecutionsCount(