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 8387563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:14:48+00:00 2026-06-09T18:14:48+00:00

I am using the following example code from https://github.com/LearnBoost/socket.io to start a Socket.IO and

  • 0

I am using the following example code from https://github.com/LearnBoost/socket.io to start a Socket.IO and Express example.

When I got to localhost, I get this error:

Cannot GET /

My app.js looks like this:

var express = require('express');
var io = require('socket.io');
var server = require('http');

var app = express()
  , server = require('http').createServer(app)
  , io = io.listen(server);

server.listen(80);

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

My index.html looks like this:

<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>

Packages:

npm ls
├─┬ express@3.0.0rc2
│ ├── commander@0.6.1
│ ├─┬ connect@2.4.2
│ │ ├── bytes@0.1.0
│ │ ├── formidable@1.0.11
│ │ ├── pause@0.0.1
│ │ └── qs@0.4.2
│ ├── cookie@0.0.4
│ ├── crc@0.2.0
│ ├── debug@0.7.0
│ ├── fresh@0.1.0
│ ├── methods@0.0.1
│ ├── mkdirp@0.3.3
│ ├── range-parser@0.0.4
│ └─┬ send@0.0.3
│   └── mime@1.2.6
└─┬ socket.io@0.9.10
  ├── policyfile@0.0.4
  ├─┬ redis@0.7.2
  │ └── hiredis@0.1.14
  └─┬ socket.io-client@0.9.10
    ├─┬ active-x-obfuscator@0.0.1
    │ └── zeparser@0.0.5
    ├── uglify-js@1.2.5
    ├─┬ ws@0.4.21
    │ ├── commander@0.6.1
    │ ├── options@0.0.3
    │ └── tinycolor@0.0.1
    └── xmlhttprequest@1.4.2

Thanks!!

  • 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-09T18:14:50+00:00Added an answer on June 9, 2026 at 6:14 pm

    You’ve not instructed Express to serve your index.html file. Probably the easiest way to get it running is to make a directory called public and put index.html in it, and modify your Express server so that it serves static files from that directory:

    var express = require('express');
    var io = require('socket.io');
    var server = require('http');
    var path = require('path');
    
    var app = express()
      , server = require('http').createServer(app)
      , io = io.listen(server);
    app.use(express.static(path.join(__dirname, 'public')));
    

    And then visit localhost/index.html in the browser.

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

Sidebar

Related Questions

Using the following code: use LWP::Simple; my $url= http://example.com; my $html= get $url; I
I followed the following QuickStart example from a brand new EmptyWebApplication: https://github.com/SignalR/SignalR/wiki/QuickStart-Persistent-Connections I installed
Consider the following example taken from http://www.albahari.com/threading/ : using System; using System.Threading; class ThreadTest
I'm trying to get JSON data from a website using the following code, but
Please forgive the verbosity of the following code example. Using Delphi 2009, I created
I'm trying to implement the example code of the following question by using opencv
I am trying to create dynamic menus from the database using the following example
Using the sample app for rpx_now gem ( http://github.com/grosser/rpx_now_example ) on localhost:3000, I have
I'm going to use the sample code from http://gettinggeneticsdone.blogspot.com/2009/11/split-apply-and-combine-in-r-using-plyr.html for this example. So, first,
I'm using the following code on my iPhone app, taken from here to extract

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.