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

370
Views
How to get the link of the created server in the http.createServer() function?

How to get the link of the created server in the http.createServer() function?

I am trying to use the http package from node.js and use the createServer() function, then I want to print the server's link with the port, like this:

const createServer = http.createServer();
const server = createServer.listen(port);

And then get the link from the createServer variable like http://localhost or from a repl.it/replit.com link . this is my code in JS:

const port = 1234;
const createServer = http.createServer();
const server = createServer.listen(port);
const websocket = new web({ httpServer: server });

console.log(createServer); // This doesnt print the server link
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can get the information about the server by calling server.address():

console.dir(server.address());

//{ address: '::', family: 'IPv6', port: 1234 }

Since you didn't specify a host when creating the server, the default one will be used which according to the documentation:

If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise.

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!