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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:45:21+00:00 2026-06-09T14:45:21+00:00

I’m making a web-app that makes use of nodejs, mongodb, socket.io, express and mongoose.

  • 0

I’m making a web-app that makes use of nodejs, mongodb, socket.io, express and mongoose.

I can start my server and correctly get the wanted html file in my browser when browsing to my localhost.
The problem I have is getting my socket.io to work.
On my server side everything works fine : I get ” info – socket.io started ” in my terminal.

But when surfing to my browser I get this in my browser console

    Failed to load resource: the server responded with a status of 404 (Not Found) 
    Uncaught ReferenceError: io is not defined 

This is how i connect to socket.io.js

    <script src="/socket.io/socket.io.js"></script>

and my map structure looks like this:

 map
  -app.js
  -public
  --index.html

  -node_modules
  --socket.io
  --mongodb
  --express
  --jade
  --mongoose

Does anyone knows what the mistake is I’ve made?

(it’s actually the same problem as here: Node.js socket.io.js not found or io not defined )

Thanks in advance!

EDIT:
My code on the server side is this:

    var app= require('express').createServer();
    var io = require('socket.io').listen(app);
    var mongoose = require('mongoose');
    var db = mongoose.connect('mongodb://localhost/db');

    app.listen(3030);
    console.log("server started");

    app.get('/',function(req,res){
res.sendfile(__dirname + '/public/index.html');
    });


    io.sockets.on('connection',function(socket){    
    console.log("connection made");
    });

The first log, gets logged in the terminal (“server started”), but the second one (“connection made”) doesn’t get logged. So the connection isn’t made.
I thought that was because of the wrong “set up” in my client side.

  • 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-09T14:45:22+00:00Added an answer on June 9, 2026 at 2:45 pm

    Check out the express migration guide 2->3
    https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x
    Something like this should work

     var express = require('express');
     var app = express();
     var http = require('http');
     var server = http.createServer(app);
     var io = require('socket.io').listen(server);
     var mongoose = require('mongoose');
     var db = mongoose.connect('mongodb://localhost/db');
    
     server.listen(3030);
     console.log("server started");
    
     app.get('/',function(req,res){
         res.sendfile(__dirname + '/public/index.html');
     });
    
    
     io.sockets.on('connection',function(socket){    
        console.log("connection made");
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a French site that I want to parse, but am running into

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.