I downloaded the React App package from the link create-react-app. The default port it assigns is port:3000
How to Change this port to a custom port like 3002 or 3006 ?
To change the default port for a create-react-app project, update the start command in your package. json file to specify the port, e.g. "PORT=3456 react-scripts start" on macOS and Linux and "set PORT=3456 && react-scripts start" on Windows.
When we create a new react app using the npx create-react-app command, the default port for the app is 3000. We can access the app from the localhost:3000.
Open C:\xampp\apache\conf, find the httpd. conf file and open with notepad++. Look for these lines and change 80 in the last line any other port, for example 8080. This way we will be able to run Apache but the http://localhost/url won't work for that you need to append port number into the URL.
modify part of package.json from:
"start": "react-scripts start"
for Linux and MacOS to:
"start": "PORT=3006 react-scripts start"
Windows to:
"start": "set PORT=3006 && react-scripts start"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With