dosn't work

So… for some reason I can’t get to work with glitch. I am very new to glitch and just tried to recreate a program i have made on my pc.

This is the socket io script in my html file.

<script src=""></script>

This is how i require socket io on server.js

var express = require("express");
var app = express(); 
var serv = require("http").Server(app);
var io = require("")(serv);

app.get('/', function(request, response) {
  response.sendFile(__dirname + '/views/index.html');

const listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);

The server runs without any errors but when i try to open a client, socket io can’t connect to the server.

I have no idea what i’m doing wrong. any help is appreciated :slight_smile:

1 Like

Could you please send your project name as it would help us answer your question.

1 Like

oh, yeah sorry
its mega-sejt

1 Like

Hey @nicklasbns I think all that you’re missing here is that you should start the listener with serv rather than app. Both your Express app and app can listen using the same server and port, but when you just listen using app your socket server’s not started.

Let us know if that helps. Happy Glitching!


Turns out your trying to make express listen, not the server.

Instead of

  console.log('Your app is listening on port ' + listener.address().port);



Hope this helps!

oh no looks like cori beat me to it within 5 seconds!


Thank you guys! it works now :+1: