Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,528 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.