# WebSocket connection to '\<URL\>' failed: WebSocket is closed before the connection is established.

**URL:** <https://forum.ansible.com/t/websocket-connection-to-url-failed-websocket-is-closed-before-the-connection-is-established/27889>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 27, 2018, 7:52pm UTC](https://forum.ansible.com/t/websocket-connection-to-url-failed-websocket-is-closed-before-the-connection-is-established/27889 "2018-06-27T19:52:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sudheer\_Jejamma](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sudheer\_Jejamma](https://forum.ansible.com/u/Sudheer_Jejamma)\
**Post date:** [June 27, 2018, 7:52pm UTC](https://forum.ansible.com/t/websocket-connection-to-url-failed-websocket-is-closed-before-the-connection-is-established/27889/1 "2018-06-27T19:52:23Z")

</div>

Hello Folks,

I’m running awx on https on port 443. I’m able to launch jobs but I’m unable to see StandardOut. Please find the following details.

**Version details:**

awx\_web:1.0.5  
awx\_task:1.0.5  
postgre:9.6

**Console Errors:**

WebSocket connection to ‘’ failed: WebSocket is closed before the connection is established.

WebSocket connection to ‘wss://awx-test.com/websocket/’ failed: Error during WebSocket handshake: Unexpected response code: 504

**nginx.conf File:**

#user awx;

worker\_processes 1;

pid /tmp/nginx.pid;

events {

worker\_connections 1024;

}

http {

include /etc/nginx/mime.types;

default\_type application/octet-stream;

log\_format main '$remote\_addr - $remote\_user [$time\_local] “$request” ’

'$status $body\_bytes\_sent “$http\_referer” ’

‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

map $http\_upgrade $connection\_upgrade {

default upgrade;

‘’ close;

}

sendfile on;

#tcp\_nopush on;

#gzip on;

upstream uwsgi {

server 127.0.0.1:8050;

}

upstream daphne {

server 127.0.0.1:8051;

}

server {

listen 443 default\_server ssl;

ssl\_certificate /etc/tower/tower.cert;

ssl\_certificate\_key /etc/tower/tower.key;

ssl\_password\_file /etc/tower/tower.pass;

ssl\_session\_cache shared:SSL:50m;

ssl\_session\_timeout 1d;

ssl\_session\_tickets off;

# intermediate configuration

ssl\_protocols TLSv1.2;

ssl\_ciphers ‘ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECD HE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256’;

ssl\_prefer\_server\_ciphers on;

# If you have a domain name, this is where to add it

server\_name \_;

keepalive\_timeout 65;

# HSTS (ngx\_http\_headers\_module is required) (15768000 seconds = 6 months)

add\_header Strict-Transport-Security max-age=15768000;

location /static/ {

alias /var/lib/awx/public/static/;

}

location /favicon.ico { alias /var/lib/awx/public/static/favicon.ico; }

location /websocket {

# Pass request to the upstream alias

proxy\_pass [http://daphne](http://daphne);

# Require http version 1.1 to allow for upgrade requests

proxy\_http\_version 1.1;

# We want proxy\_buffering off for proxying to websockets.

proxy\_buffering off;

# [X-Forwarded-For - Wikipedia](http://en.wikipedia.org/wiki/X-Forwarded-For)

proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

# enable this if you use HTTPS:

proxy\_set\_header X-Forwarded-Proto https;

# pass the Host: header from the client for the sake of redirects

proxy\_set\_header Host $http\_host;

# We’ve set the Host header, so we don’t need Nginx to muddle

# about with redirects

proxy\_redirect off;

# Depending on the request value, set the Upgrade and

# connection headers

proxy\_set\_header Upgrade $http\_upgrade;

proxy\_set\_header Connection $connection\_upgrade;

}

location / {

# Add trailing / if missing

rewrite ^(._)$http\_host(._[^/])$ $1$http\_host$2/ permanent;

uwsgi\_read\_timeout 120s;

uwsgi\_pass uwsgi;

include /etc/nginx/uwsgi\_params;

}

}

server {

listen 80 default\_server;

server\_name \_;

return 301 $https://$host:8443$request\_uri;

}

}

Can some one please suggest why I’m getting the issue?

Thanks,  
Sudheer.

---

<div class="post-metadata">

**Author:** ![Ahamed\_Fazlul\_Wahab1](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@Ahamed\_Fazlul\_Wahab1](https://forum.ansible.com/u/Ahamed_Fazlul_Wahab1)\
**Post date:** [June 25, 2019, 6:25am UTC](https://forum.ansible.com/t/websocket-connection-to-url-failed-websocket-is-closed-before-the-connection-is-established/27889/2 "2019-06-25T06:25:07Z")

</div>

I know its an old post, but thought it’d be helpful to let everyone know how I fixed the same issue.

There was nothing wrong with the nginx.conf. In my case I had configured an unsupported password for “rabbitmq\_password” in the inventory file before running setup. The password can have only alpha-numeric characters and cannot have any special characters.

Once correct password is given and re-run setup everything works fine.
