How to resolve a 404 (Not Found) error?

cannot get / eio=3&transport=polling&t=ldmmkyz
socket = io client
failed to load resource: the server responded with a status of 404 (not found socket = io)
socket = io reconnect
socket = io websocket
socket = io ping pong
socket io java
what is socket io used for

I am using with Express. In my project I have a login page and a home page. When I do successful login, I navigate to localhost:3000/home where I get this error:

GET http://localhost:3000/ 404 (Not Found)

I did not do any modification in my app.js (project created by express ).


var express = require('express');
var router = express.Router();
var http = require('http');
var fs = require('fs');
var io = require('')(http);
/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'Express' });

router.get('/home', function(req, res) {
  res.render('home', { title: 'Express' });

io.on('connection', function(socket){
    console.log("User Connected");
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
   socket.on('disconnect', function(msg){
    console.log("User DisConnected");

});'/authenticate', function(req, res) {
    fs.readFile("./public/Verification/Users.json", "utf8", function (err, data) {
        if (err) 
            var result = JSON.parse(data);
            for(var i=0;i<result.Users.length;i++){
                if(req.body.username == result.Users[i].username && req.body.password ==     result.Users[i].password){

module.exports = router;

In my layout.jade I defined like this:


If you're running Express 4, it appears to me like you're missing the lines of code:

var app = express();
var server = app.listen(3000);

That will start your web server and set it to port 3000. See the bone simple Express 4 app here:

And, then to start up, you would add:

var io = require('').listen(server);

And, there is no need for this line:

var http = require('http');

How to resolve a 404 (Not Found) error?, var socket = io. connect(''); This corrects the getJSON queries URL and adds the correct port and no more 404. I hope it helps someone in the future. Probably what you want to do is to share your same express server with (this is how is usually used). In your code, you can do that by removing those two lines above and then inserting one line here at the end:

Since I was battling with this issue for the past 5 hours. And this is the first result in google.

Of course its 2015 and some of the code has changed.

I think currently the best start of the index.js code is:

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


The order is highly important.

My problem was, that everything was installed properly and node was listening. However the and was 404 not found. However, when I tried everything worked. So now was the question, how to change the getJSON query to have the port part.

So the solution was to edit the main.js, that is being added to the index.html, where your chat is. There is:

var socket = io();

to be replaced with

var socket = io.connect('');

This corrects the getJSON queries URL and adds the correct port and no more 404. I hope it helps someone in the future.

GET http://localhost:8001/ 404 (Not , is not getting the error message http://localhost:8001/​ 404 (Not Found) from the browser  How to Fix the 404 Not Found Error Retry the web page by pressing F5, clicking/tapping the refresh/reload button, or trying the URL from the address bar again. The 404 Not Found error might appear for several reasons even though no real issue exists, so sometimes a simple refresh will often load the page you were looking for.

This is how i solve it on server side (2018):

const app = express();
const socketIO = require('');

const server = express()
  .listen(PORT, () => console.log(`Listening Socket on ${ PORT }`));

const io = socketIO(server);

On client side

<script src=""></script>

It looks easy but I spent hours before I found the solution since the solutions above didn't work for me.

Client not found 404 · Issue #936 · socketio/ , 6) with express (3.00b4) and node (0.8.1). On a localhost. When I create the base epxress server the client is not found. I've tried  How are websites accessed? 06.09.2019; Web development; In order to access a web page in a browser, you just have to enter the URL into the address bar in your web browser and the requested website will pop up on your screen.

Please change your config to this

var express = require('express');

// App setup
var app = express();
var socket = require('')

var server = app.listen(4000, function(){
    console.log('listening for requests on port 4000,');

let io = socket(server)
io.on('connection', function(socket){
  console.log(`${} is connected`);

Socket.IO, Error during WebSocket handshake: Unexpected response code: 400. Which means that the upgrade request was sent to a node which did not know the That's why you might find some suggestions to only use the WebSocket transport:​  Here are some checks to perform to resolve a 404 error: 1) Review the deleted pages If you have deleted pages on your website, the search engines may have found and indexed it .

just call the listen of the server and with the callback I passed the server instance to module.

part of the bin/www file from express app

var server = http.createServer(app);
server.listen(port, function () {
  console.log('app listening on *:' + port);
  console.log('socket server will be on *:' + port);

server.on('error', onError);
server.on('listening', onListening);

and this is how my socket module socket.js

var io = {};

module.exports = (server, serveradmin) => {
  io = require('')(server);
  io.on('connection', function (socket) {
    console.log(socket + ' a user connected');

all of the socket listeners and emits managing from here.

Socket.IO, for the protocol can be found here:​protocol This module is not intended for end-user usage, but can be used as an  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together., js found in the dist folder or include it via CDN. <script src="  The 404 is an http status code. There are many other status codes as 401, 403, etc. Every status code has its own meaning. The 404 code means the requested item could not be found. The http status code is a standard response code given by web servers on the Internet. The status code is a 3-digit integer where the first digit defines the class, A heartbeat mechanism is implemented at the Engine.IO level, allowing both the server and the client to know when the other one is not  IIS6 Dynamic Content: A 404.2 entry in the W3C Extended Log file is recorded when a Web Extension is not enabled. Use the IIS Microsoft Management Console (MMC) snap-in to enable the appropriate Web extension.

How do I link a Js file to index.html that was served to the browser , GET http://localhost:8080/ net:: ERR_ABORTED 404 (Not Found) the files exist but its not find them after the html gets served well, otherwise you are only “sending back” the html, hence the 404 errors. Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

  • Where is your express server configured to listen on port 3000? I don't see that part anywhere? And, it would need to be before you hook up io server side.
  • By default it is listening to 3000. I did not configure anything.
  • There is no default on port 3000 that I'm aware of. If localhost:3000/home generates an error, then you don't have your web server working properly on port 3000. Which version of Express are you running?
  • Yes i am using express 4. I placed this code in app.js and it is giving me "EADDRINUSE" error.
  • Yep working!! By mistake i added the same code in index.js , and thats where it was giving error. Thanks.
  • Thank you, saved my day
  • Excellent thanks brother i was also messing around with this
  • The selected solution did not work but this one did :) Thank you :)
  • I will also add a note here of a problem, that everyone starting with these sockets. That those nodes do not stay alive. When you close your console, they will die out. For that you have to install an addon, that will keep the nodes alive. I sadly do not remember anymore, but I think it was Nevertheless you need something extra to keep the node alive.
  • I tried to see the nginx conf, and added following line there:
  • what's the point of doing app = express(); and then server = express().use(app) ? Is it on purpose or it's just a mistake?
  • Thank you very much, this is exactly what I was looking for.