0

"scripts": { "start": "react-scripts start", "server": "nodemon server ", "client": "npm start --prefix client ", "dev": "npx concurrently "npm run server" "npm run client""

This is the code on my server package json when I npm run dev it opens localhost 3000 which should have my frontend application but instead opens a new react app local host 3000

If I log into my frontend and run,it runs successfully on local host 3000 or sometimes claims that local host 3000 is occupied and changes the port number to local host 3001

I need For the npm run dev to open both client and server concurrently therefore opening the correct localhost 3000 which contains project interface

  • 1
    Could you share port setting for both client and server sides? My assumption is you are using the same 3000 port for both of them. – Nattapon Aiemlaor Jan 06 '23 at 15:14
  • const PORT =process.env.PORT || 7809 app.listen(PORT, console.log(`Server running in ${process.env.NODE_ENV}mode on port ${PORT}`.yellow.bold)); – mercy mwangi Jan 07 '23 at 10:47
  • Could you try changing the either ClientSide or ServerSide PORT to something else? – Nattapon Aiemlaor Jan 07 '23 at 10:49
  • You can now view tracker in the browser. Local: http://localhost:3000 This is my client side port successfully opening on port 3000 Yes I did try changing the port number on the server side very hectic if you ask me I kept killing the ports and relaunching but the issue was still there – mercy mwangi Jan 07 '23 at 10:54

1 Answers1

0

I believe you are trying to run both processes on the same PORT.Well it is not convenient to run two process on a single port concurrently you need to specify two distinct PORTs for each process.

Refer: Can two applications listen to the same port?

Sardar
  • 186
  • 5