Skip to content

Server Doesn't Release Port 3000 on Ctrl+C (limited branch) #224

Open
@yuliabo

Description

@yuliabo

When stopping the server using Ctrl + C, the port (3000) remains occupied, causing the error:
Error: listen EADDRINUSE: address already in use :::3000
This requires manually killing the process before restarting the server, which is inconvenient.

Solution:
Modify server.js to handle the SIGINT signal and close the server properly:
process.on('SIGINT', () => { console.log('\nShutting down server...'); server.close(() => { console.log('Server stopped.'); process.exit(0); }); });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions