Added fallback when port in use (#2524)

* Added fallback when port in use

*  Minor Fixes
This commit is contained in:
Anuj Kapoor 2021-12-10 20:02:32 +05:30 committed by GitHub
parent 2125f25791
commit 8d2c6cc073
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2905,6 +2905,15 @@ export async function start(): Promise<void> {
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(