DEV Community

Doaa Mahely
Doaa Mahely

Posted on

Can't connect to remote server running


It turns out the port 3000 on the remote server wasn't open. Thanks everyone for reading.


Hello everyone.

I have a client that I connect to the server I'm running in my localhost using

const io = require('');
const chatSocket = io.connect('');

Everything works well and I can send messages through the socket that are logged in the server.

This is the code I use on the server side:

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

io.on("connection", function() {

http.listen(port, function () {
  console.log("listening in port 3000");

The problem is that "connected" never logs when I run the same code on a remote server. Just the "listening in port 3000" part. I'm substituting the server's IP address and port in io.connect(). I even tried with the DNS name but it's still not connecting. I've checked the dependencies and they're the same as my local environment.

What could I be missing?

Top comments (4)

brandinchiu profile image
Brandin Chiu

Where are you setting your port variable on your server side? Also note that your front end lists the port number as 7000, but your comment on the server mentions 3000.

dmahely profile image
Doaa Mahely

Hello Brandin. My bad, I'm connecting to port 7000 on my local which works, but connecting to port 3000 on the remote server. I'm starting to think port 3000 is closed or something.

nayhtoonaing48 profile image

Hello devs, I have the same problem with Unity Client and Node js +,
How to solve this problem ,

dmahely profile image
Doaa Mahely

Hello there. Do you wanna post your code so we can take a closer look?