Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

476
Views
NodeJs Error: Port already in use:3000 using socket.io and express

I'm making a node.js application that uses socket.io and express.

The code looks like this-

const express=require('express');
const app=express();
const http=require('http').Server(app);
app.use(express.static('public'));

const io=require('socket.io')(http,{
  cors:{origin:'*'}
});

http.listen(3000,()=>{
  console.log('listening to port 3000');
});

//when connection made 
io.on('connection',(socket)=>{
  console.log('connection made!');
});

Here,public is a folder container all the html files for the website.

Now,when I run it locally on my pc,it works fine But when I deployed it on the glitch.com servers,i get this error:

Error: listen EADDREINUSE: address already in use :::3000

As far as i know,3000 is the only available port in glitch and I cannot use another port.

Also,the questions on stack overflow related to this topic doesn't help me since most of the answers are related to killing the running tasks themselves and I don't have permission to do so on the server.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

This often happens when your server is still running in error, try switching listening to 3001 and see if there is still the error

about 4 years ago · Juan Pablo Isaza Report

0

free your 3000 port:

Linux: fuser -k 3000/tcp

about 4 years ago · Juan Pablo Isaza Report

0

According to this question on glitch.com's forums you might have two services listening to the same port, but that doesn't seem to be the case.

You should also be able to change the default listening port by setting the PORT environment variable in your .env file if you have one. Trying a different port should solve the problem

EDIT: Apparently the problem could be the initial configuration of the server, you can try setting everything up like this:

const app = require('express')();
const server = require('http').createServer(app); <--
const io = require('socket.io')(server);
io.on('connection', () => { /* your code */ });

server.listen(process.env.PORT, () => {/* your code */});

(Got this from socket.io github page)

If this doesn't work either you should try asking on glitch.com's support forums, one of their technicians will help you better troubleshoot your problem, they have all the necessary tools

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!