Node.js Error when trying to connect client to server

Greetings all,

I am trying to create a Web chat and to do this 1st we need to set up a client to server connection via Node and - and it is not working.

The server code is here:

And it runs fine when started via: node server.js
printing results to putty command line of: “Socket io Server Chat Started On V4 3000”

But on client side the connection is not happening :frowning:
And we have tried in both ways as stated by Get Started, which are:

via io global as you can see here:

this results in Error:
Failed to load resource: the server responded with a status of 404 (Not Found)
Uncaught Reference Error: io is not defined at (index):14

And via local version of the client-side JS file which can be reached via: node_modules/
as you can see here:

this results in Error:
polling-xhr.js:157 GET 404 (Not Found)

So what are we doing wrong? How can we connect the client side Web page to server?


The easiest solution is to use CDN version (which many of your clients will already have in cache) and manually specify connection URL and path. Don’t forget to add port (:3000) after the domain in URL.





What do you mean by " easiest solution is to use CDN version"?
If you mean to link to a 3rd party URL from client browser, for various reasons we cannot do this and all
recourses need to be served from our server.

So all I am asking Help with is why doesnt the client browser connect to the node.js based server via:


and client throws the Errors:

Failed to load resource: the server responded with a status of 404 (Not Found)

Uncaught ReferenceError: io is not defined

Thank you Node.js GODs :slight_smile:

  1. Your server listens on port 3000
  2. SSL is not available at the moment, you have to manually specify paths to SSL-certificate files in your server code

Hello Veo,

I followed your instructions from that server code page, and created new server - here:

the server starts OK with message to console of:

“Socket io Server Chat Started in SSL mode via https, on Port: 3000”

but again the client side it does not connect. And I tried both ways for:


What is going ON :frowning:
i really appreciate the support of Node.js GODs here to resolve this as it has been almost
5 days I have been trying to figure this out to get between client and server established so we can move in with the main of this development.

Thanks again all

You missed the important part: listen() has to be called twice, on both server and io instances:


Try to add this line to the end of server_ssl.js:


I did your code, here:

and upon starting it, it throws this ERROR:

[root@mail chat_app]# node veo_server.js
var io = require(‘’).listen(server);

TypeError: require(…).listen is not a function
at Object. (/var/www/html/
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.