Home > Net >  Is it possible to run nodejs server and react server on single port?
Is it possible to run nodejs server and react server on single port?

Time:11-05

I want to run both react and node on single server because i don't want to start it together. like when i run npm start both will be run because i want to run project using electronjs.

I tried to run command npm start client.js server.js but it didn't work

CodePudding user response:

you can't run 2 servers in the same port and the same IP you should run each one on a different port, react has a default port(3000) to run on you should set your nodejs server to another one like 8000.

CodePudding user response:

You cannot do that you'll need two different port numbers 3000 for server 3001 client...
otherwise, you can use Docker to run on the same port and map to your host on different ports with docker commands:

docker run CLIENT_IMAGE -p 3000:3000
docker run SERVER_IMAGE -p 3001:3000

Good luck!

  • Related