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

205
Views
Node.js net.Socket().connect() hangs and doesn't connect to server

I have a server and a client set up using the net module for Node.js.

Here is my server's code:

const server = net.createServer(function(socket) {
    socket.on("data", function(data) {
        // Do stuff with the connection
        socket.end();
    });
});
server.listen(this.port);

Here is my client's code:

const client = new net.Socket();
client.connect(this.port, this.host, function() {
    client.write("Test Message");
});

When run on the same machine, both of these work fine, but when I try to connect from a different computer, the client hangs at client.connect() forever (until I terminate the process). When I tried to use the telnet command in command prompt, I don't get a response from the server, but the client doesn't just say connection refused. What's going on here?

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