not found

For some reason my node server cannot serve the route /, I always get a 404 error.
I tried compiling different node versions (current is 0.6.13 which also runs on server, where it actually works).
From the app.js I get info: started and no error when trying to call the

I try it from localhost and port 8000 and I use the express framework

This is the code from app.js:

var express = require('express')
  , app = require('express').createServer()
  , io = require('').listen(app, { log: true });


app.configure(function() {
    app.use(express.static(__dirname + '/public'));
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));

io.sockets.on('connection', function (socket) {
   // all other stuff here



Please check your Express version. Express recently is updated to 3.0alpha which API was changed. If 3.0 you can change your code to something likes this:

var express = require('express')
  , http = require('http');

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



Same issue with connect:


Using with the Express 3 web framework: (from

> Express 3 requires that you instantiate a http.Server to attach to first:

meaning - (1) you must create a server instance:

var app = express();
var http = require('http').createServer(app);

(2) couple it with the

var io = require('');

and ONLY THEN - (3) make the server listen:


make sure you keep this order!


After installing node 0.8.1 I had the same problem. I just deleted the node_modules map in my project folder and reinstalled express/ After that it worked fine again with the code in your question.


Maybe this could help you, on my Ubuntu 11.10 I haven't properly set NODE_PATH variable, If you are on linux/mac try add line below to your .bashrc/.zshrc file.

export NODE_PATH=/usr/lib/node_modules:$NODE_PATH

Install inside your repository:

npm install --save 

After, config the server:

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

   server.listen(app.get('80')); // not 'app.listen'

And inside your archive HTML/EJS or another you want, add:

<script src="/"></script>

Check if works with Console (Chrome/ Mozilla, etc).

In my example I use Chrome (Ctrl + shift + I):

enter image description here


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.