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

  • Home
  • SEARCH
  • 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 7551047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:22:41+00:00 2026-05-30T10:22:41+00:00

I’m having trouble even getting the very basic socket.io sample to run. For example

  • 0

I’m having trouble even getting the very basic socket.io sample to run. For example the first example on the welcome page of their site:

var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

on the server side and

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('http://localhost');
  socket.on('news', function (data) {
    console.log(data);
    socket.emit('my other event', { my: 'data' });
  });
</script>

on the client side. If I save the server-side in a host.js file, and the client-side in a client.htm file, and I run npm host.js, I get

   info  - socket.io started
   warn  - error raised: Error: listen EADDRINUSE

which is already not really expected. Then, for the client.htm (or at least that’s what I think that I’m supposed to do with it — pasting it in a client.htm file), I only get a blank screen. Not very surprising, since it starts by including a nonexisting file /socket.io/socket.io.js, but even changing this to host.js (which I assume it is supposed to be) doesn’t change the fact that I only get a blank screen…

I’m clueless.

  • 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-05-30T10:22:43+00:00Added an answer on May 30, 2026 at 10:22 am

    EADDRINUSE means that address is already in use so it can’t get the socket. Is something else already running on port 80 on your machine? 80 is commonly used by web servers.

    You can also try it on some other port.

    The reason you see a blank file is it doesn’t connect to the node server (since it couldn’t get the socket) so the on news event will never get called. It might even connecting to the socket of whatever else is running on 80 which will never emit that event 🙂

    After you solve the port conflict, when you run the server, it should just say:

    info – socket.io started

    and now it’s waiting for connections.

    Make sure you update the htm line to your port. For example, if 81:

    var socket = io.connect('http://localhost:81'); // note the :81
    

    EDIT:
    I just tried it out and in the htm file I had to set the relative path to the socket.io.js file. After installing it via npm it was here in my directory.

    <script src="node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js"></script>
    

    Make sure that path is relative to the htm file (doesn’t start with a /). Here’s how I found out where mine was:

    find . -name 'socket.io.js'
    

    On Win:
    dir socket.io.js /s

    You should also run the host with (on *nix you may need sudo in front):

    node host.js
    

    Last thing I did when trying the sample was changing a couple lines in the htm file to this so I could see an alert message box when the event happened:

    socket.on('news', function (data) {
       alert(JSON.stringify(data));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I would like to run a str_replace or preg_replace which looks for certain words

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.