# Apache Proxy Websocket Unexpected response code: 400 problem

**URL:** <https://forums.rocket.chat/t/apache-proxy-websocket-unexpected-response-code-400-problem/6912>\
**Category:** Development\
**Created:** [May 12, 2020, 9:04pm UTC](https://forums.rocket.chat/t/apache-proxy-websocket-unexpected-response-code-400-problem/6912 "2020-05-12T21:04:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![enes.selcuk](https://avatars.discourse-cdn.com/v4/letter/e/dfb087/32.png) [@enes.selcuk](https://forums.rocket.chat/u/enes.selcuk)\
**Post date:** [May 12, 2020, 9:04pm UTC](https://forums.rocket.chat/t/apache-proxy-websocket-unexpected-response-code-400-problem/6912/1 "2020-05-12T21:04:38Z")

</div>

Hello, I am having a problem with websocket. Can you help here? I installed rocketchat. I activated the required modules on Apache 2.4. I have defined the proxy rules but the error “failed: Error during WebSocket handshake: Unexpected response code: 400” is received. "

### Server Setup Information

- Version of Rocket.Chat Server: rocketchat-12.14.0
- Operating System: Ubuntu 20.04
- DB Replicaset Oplog:
- NodeJS Version: v12.16.3
- MongoDB Version: v4.0.18
- Proxy Definitions

\<Proxy \*\>  
Order deny,allow  
Allow from all

ProxyRequests Off  
ProxyPreserveHost On  
ProxyPass /chat 192.168.0.148:3000/chat  
ProxyPassReverse /chat 192.168.0.148:3000/chat

\<Location /chat\>  
Order allow,deny  
Allow from all

```
RewriteEngine On

RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /var/www/(.*) ws://192.168.0.10:3000/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /var/www/(.*) 192.168.0.10:3000/$1 [P,L]

```

RocketChat Service Definitions

Rocket Chat Environment  
ROOT\_URL=“http [test.server.com](http://test.server.com) chat”

ERRORS:

WebSocket connection to ‘wss://test.server.com/chat/sockjs/381/fj3jxqqr/websocket’ failed: Error during WebSocket handshake: Unexpected response code: 400

---

<div class="post-metadata">

**Author:** ![enes.selcuk](https://avatars.discourse-cdn.com/v4/letter/e/dfb087/32.png) [@enes.selcuk](https://forums.rocket.chat/u/enes.selcuk)\
**Post date:** [May 12, 2020, 9:05pm UTC](https://forums.rocket.chat/t/apache-proxy-websocket-unexpected-response-code-400-problem/6912/2 "2020-05-12T21:05:46Z")

</div>

> [@enes.selcuk](#):
>
> http

http:// I had to add http instead. Because while creating a topic, it gives maximum 2 permissions.

---

<div class="post-metadata">

**Author:** ![enes.selcuk](https://avatars.discourse-cdn.com/v4/letter/e/dfb087/32.png) [@enes.selcuk](https://forums.rocket.chat/u/enes.selcuk)\
**Post date:** [May 13, 2020, 11:43am UTC](https://forums.rocket.chat/t/apache-proxy-websocket-unexpected-response-code-400-problem/6912/3 "2020-05-13T11:43:04Z")

</div>

problem is solved.  
\<Proxy \*\>  
Require all granted

AllowEncodedSlashes On

ProxyRequests Off  
ProxyPreserveHost On

ProxyPass /chat [http://192.168.0.10:3000/chat](http://192.168.0.10:3000/chat)

\<Location /chat\>  
Require all granted  
RewriteEngine on  
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]  
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]  
RewriteRule .\* ws://192.168.0.10:3000%{REQUEST\_URI} [P]

ProxyPassReverse /chat 192.168.0.10:3000/chat

\<Location /chat\>  
Require all granted
