Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9274959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:28:34+00:00 2026-06-18T16:28:34+00:00

I just created a node.js chat app.. but the app doesn’t load. The code

  • 0

I just created a node.js chat app.. but the app doesn’t load.
The code is very basic node.js chat app:

// Load the TCP Library
var net = require('net');

// Keep track of the chat clients
var clients = [];

// Start a TCP Server
net.createServer(function (client) {

    console.log("Connected!");

    clients.push(client);

    client.on('data', function (data) {
        clients.forEach(function (client) {
            client.write(data);
        });
    });

}).listen(5000);

// Put a friendly message on the terminal of the server.
console.log("Chat server is running\n");

After I compile it, I write in the chrome browser localhost:5000 but the page is keep loading and never finish.

However, the following code works perfectly:

// Load the TCP Library
net = require('net');

// Start a TCP Server
net.createServer(function (client) {
    client.write("Hello World");
    client.end();
}).listen(5000);

I run Windows 7 64 bit on my computer, and I’m using chrome.

Thanks in Advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:28:35+00:00Added an answer on June 18, 2026 at 4:28 pm

    You are creating a TCP/IP server by using the net module, but you are accessing it using the http protocol using your web browser.

    This does not match each other.

    Try to connect to your server using telnet, e.g., and everything should be fine.

    Alternatively, if you want to be able to connect using your webbrowser, you need to use the http module instead of the net module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just created a WSS site with a some custom web-parts. But I get an
I just created my first jQuery plugin , it is very simple it slideToggle
I just created a web app available offline with the cache manifest etc. It
I created an upload script in node.js using express/formidable. It basically works, but I
Im just learning javascript and I'm just wondering why this doesn't work. I've created
I've created a node module that is essentially just some useful JS that can
Drupal 6. I have created a node type which consists of just a body
I created a basic node linked list that displays the size of the list
Just created a .dll file that has some methods. And I have a another
Just created an acc on SO to ask this :) Assuming this simplified example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.