Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!