title: How can I change the default port in react from 3000 to another port?
body: <h2>how to change react default port 3000 to others port ?</h2>
  
  <p>By default, a ReactJS app runs on port 3000. An Express.js app also runs on the same port 3000. If you were to run the two apps simultaneously, there would be conflicts. You need to change the port of one of them.
  In ReactJS, the easiest way to alter the port number is by setting an environment variable named PORT to the desired number via the terminal. As an example, here we change the port number to 5000.</p>
  
  <p>if you use In Linux and Mac terminals, it would be</p>
  
  <pre><code>$export PORT=5000
  </code></pre>
  
  <p>or if you use In Windows, the command is slightly different</p>
  
  <pre><code>$env:PORT=5000
  </code></pre>
  
  <p>and finally start npm</p>
  
  <pre><code>npm start
  </code></pre>
  
  <h3>NB: It is for .env file</h3>
  
  <p>If you want to modify your package.json
  Default is</p>
  
  <pre><code>"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
  </code></pre>
  
  <p>and modify by </p>
  
  <pre><code>  "start": "PORT=2000 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
  </code></pre>
  
  <p>and finally run again</p>
  
  <h2>I use this</h2>
  
  <p>modify your package.json Linux and MacOS :</p>
  
  <pre><code>"start": "PORT=3006 react-scripts start"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>"start": "export PORT=6000 react-scripts start"
  </code></pre>
  
  <p>or Windows </p>
  
  <pre><code>"start": "set PORT=6000 &amp;&amp; react-scripts start"
  </code></pre>
  
  <p>and finally restart npm</p>
  
  <p>I try to change default port by using this and success, So you can try</p>
  
  <h1>If better solution Please help me</h1>