# Websockets/react - net::ERR\_CONNECTION\_REFUSED

**URL:** <https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710>\
**Category:** General\
**Created:** [November 18, 2019, 8:50am UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710 "2019-11-18T08:50:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![silvercut](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@silvercut](https://forum.freecodecamp.org/u/silvercut)\
**Post date:** [November 18, 2019, 8:50am UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710/1 "2019-11-18T08:50:55Z")

</div>

Hi there,

I am coding along the following : [https://www.youtube.com/watch?v=ZwFA3YMfkoc&t=234s](https://www.youtube.com/watch?v=ZwFA3YMfkoc&t=234s)

At the 1 hour 16 stage, i have come across an error when i try to enter the chat message:

```auto
GET http://localhost:5000/socket.io/?EIO=3&transport=polling&t=MvziWt_ net::ERR_CONNECTION_REFUSED

```

```auto
TypeError: Cannot read property 'room' of undefined
    at Socket.socket.on (C:\Users\Yaz\react projects\chat-app-3\server\index.js:38:16)
    at Socket.emit (events.js:198:13)
    at C:\Users\Yaz\react projects\chat-app-3\server\node_modules\socket.io\lib\socket.js:528:12
    at process._tickCallback (internal/process/next_tick.js:61:11)
[nodemon] app crashed - waiting for file changes before starting...

```

I can’t quite see what is happening and why it would throw an error (new to sockets). the error is either in the front-end (Chat.js) or server (index.js):

> <https://github.com/SilvercutYaz/chat-app/blob/master/client/src/components/Chat/Chat.js>

  

> <https://github.com/SilvercutYaz/chat-app/blob/master/server/index.js>

Completed repo is below:

> **[adrianhajdin/project\_chat\_application](https://github.com/adrianhajdin/project_chat_application)**
>
> This is a code repository for the corresponding YouTube video. In this tutorial we are going to build and deploy a real time chat application. Covered topics: React.js, Node.js, Express.js, and Soc...

I would appreciate your help to see why is there an error so i can understand sockets more.

thanks,  
yaz

---

<div class="post-metadata">

**Author:** ![caro1](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@caro1](https://forum.freecodecamp.org/u/caro1)\
**Post date:** [July 16, 2020, 11:08pm UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710/2 "2020-07-16T23:08:21Z")

</div>

I’m having the same issue and following the same video, did you ever figure it out?

---

<div class="post-metadata">

**Author:** ![soumyab95](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/soumyab95/32/134562_2.png) [@soumyab95](https://forum.freecodecamp.org/u/soumyab95)\
**Post date:** [November 18, 2020, 3:40pm UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710/3 "2020-11-18T15:40:00Z")

</div>

Hey,

I was facing a similar issue.  
Turns out , it has got to do something with the port number 5000.  
I changed my port to some random port (3030 for eg.) and everything worked as expected.

---

<div class="post-metadata">

**Author:** ![Ayotunde24](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ayotunde24/32/138865_2.png) [@Ayotunde24](https://forum.freecodecamp.org/u/Ayotunde24)\
**Post date:** [January 3, 2021, 11:54am UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710/4 "2021-01-03T11:54:10Z")

</div>

Hi there, I faced a similar issue  
Just add this to your server  
Const io=socketio(server,{cors:{  
origin:‘[http://localhost:3000](http://localhost:3000)’,  
methods:[‘GET’,‘POST’],  
credentials:true  
}  
})  
This worked for me

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:25am UTC](https://forum.freecodecamp.org/t/websockets-react-net-err-connection-refused/326710/5 "2021-01-16T11:25:53Z")

</div>


