Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
Is it possible to run Node and React in the same port?

I am building a simple project using React and I want it to be connected to a database (mongodb Atlas). however, I can only connect to my database using Node. Is it possible to run both Node and React on the same port 3000?

I also use Express together with Node because I find it very convenient using ejs files when making new pages with the same navBar and footer.

Is it possible to run these 3 guys together in one port?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Yes and no. In production Express will serve a static route pointing to your build folder, on the same port. In development mode, Express and React will need to separate ports. You can easily achieve that by setting Express on port 5000 and React on port 3000. Then you will need to declare this "proxy": "http://localhost:5000", in your React package.json. You can even run both Express and React simultaneously in one command if you install the package "concurrently".

over 4 years ago · Santiago Trujillo Denunciar

0

You can proxy your api by adding the following proxy field to your package.json in your react project

  "proxy": "http://localhost:4000"

Now in the frontend application you can make fetch API call using the app port e.g.

fetch('/api/user') // this calls -> http://localhost:4000/api/user

Read more here:: Proxying API Requests in Development

over 4 years ago · Santiago Trujillo Denunciar

0

Well, it's senseless to have same port for different server. However, you want to replace ejs and use react inside node server, then you can host the project in single port. But it will be difficult for everyone, the developer, the users.

So, use different project directory for serving client and the server. If you are facing some issue with the connection to the database, and feeling the one port is only working, you can change the port for them.

However, I think this post should help you to connect mongodb?

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda