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

116
Vistas
Connect servers running on two ports

I'm a big newbie when it comes to JS and web apps. I have two servers running on my computer on two different ports (5000 and 5001). The 5000 server provides a route that needs to communicate with the server on port 5001, and I can't seem to make that work.

I'm using express.js and xhr2 for the HTTP requests. There seem to be a problem with my url. Am I not supposed to look for the port at the 0.0.0.0 address ? (I have tried using the localhost one as well and it's not working).

You can find below an example of such a route. Thanks for your help !

app.get('/user', (req, res) => {
   var url = "0.0.0.0:5001/user"
   var XMLHttpRequest = require('xhr2')
   var xhr = new XMLHttpRequest();
   xhr.open("GET", url, true);
   console.log(url)
   xhr.addEventListener('readystatechange', function() {
           if (xhr.status == 200) {
               res.status(200).send(xhr.responseText)
           }
       });
   xhr.send();
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try localhost:port or 127.0.0.1:port, maybe that works

edit: yea you forgot the schema, try "http://localhost:5001/user" or the same with https instead. (credit @Heiko Theiße)

about 4 years ago · Juan Pablo Isaza 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