When My Webpack 4 Server Suddenly Stopped Working
- By : Mydatahack
- Category : Front-End, Web Technologies
- Tags: React, Troubleshoot, Webpack
Now, I have a React development environment with webpack 4 set up on my local Windows 10 machine (How to set up local development environment for React with webpack 4 and babel 7).
I have encountered a few occasions that the webpack server suddenly stopped starting and giving me the error below. This happens to the folder where it was working previously.
It took me a while to why this is happening, but I found out a workaround to get the server going. I hope you are not having this issues, but if you are, this post might help you to save a few hours of banging your head against the brick wall.
events.js:183 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE 127.0.0.1:3000 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at Server.setupListenHandle [as _listen2] (net.js:1351:14) at listenInCluster (net.js:1392:12) at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! ReactNpm@1.0.0 start: `webpack-dev-server` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ReactNpm@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
In my case, this happens when the server doesn’t get terminated correctly. From the command line interface, you should see the below termination confirmation message as below after pressing ctrl + c.
Terminate batch job (Y/N)?
For a few occasions, the server terminated without asking the confirmation. This is when the server doesn’t get terminated correctly and you cannot start another webpack server.
The workaround is to terminate the node task from Task Manager. Once this is done, you can restart the server with npm start.
Yay!