Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Building Applications with React and Redux Getting Started with Redux Redux Initial Setup - index.js

Solution to the "Error: listen EADDRINUSE 127.0.0.1:8080"

Hello,

Just sharing a solution to the errors below, when you run "npm start" and a port is already in use:

Error: listen EADDRINUSE 127.0.0.1:8080" (or EADDRINUSE 127.0.0.1:3000)

1) Type "netstat -aon" on Command Prompt

2) Find the relative PID number to 127.0.0.1:8080 (or 3000)

3) Run "taskkill /f /pid pidnumber"

4) Run "npm start" again

2 Answers

Steven Parker
Steven Parker
229,708 Points

Sure, but before you do a brute-force kill of a running task, you may want to determine what that task is and perhaps why it was running.

tasklist /FI "PID eq pidnumber"

That command will show you the name of the running program with that pidnumber.

Simon Olsen
Simon Olsen
3,597 Points

leo3 your solution didn't work for me on my Mac.

I had a bit of a google around and found a snippet to add to the webpack.config.js file which will run the dev environment on a different port to 8080.

After the module: block, you need to add

devServer: {
    historyApiFallback: true,
    contentBase: "./",
    port: 3000
  }

So your full webpack.config.js file should look like this...

module.exports = {
  devtool: "inline-sourcemap",
  entry: "./index.js",
  output: {
    filename: "bundle.js"
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loaders: ["react-hot", "babel"]
      }
    ]
  },
  devServer: {
    historyApiFallback: true,
    contentBase: "./",
    port: 3000
  }
};

Hope this helps someone out.