Adonis websocket on production


hi guys

im using adonis on local with websocket and it its working good

in production, it is not working

adonis:websocket creating socket connection on wss://{domain-name}/adonis-ws url +2s ws.browser.js:1139:109 Firefox can’t establish a connection to the server at wss://{domain-name}/adonis-ws.

the error is like that


Are you running your server behind a proxy?
And can u share the screenshot of the real error?



yeah, because i redirect my domain to an ip address

the config is like this sir



The host entry is for port 80 and Firefox is trying to a secure Websocket connection, which will be over port 443.


hi sir virk, sorry but i cant understand your reply, would you mean that i need ti change the port 80 above to 443?


The virtual host entry you have is for the port 80 right. <VirtualHost *:80>. Whereas the browser is making a request on port 443, because it is using wss://.

So you need to change or declare a new VirtualHost entry for 443.

A normal google search can also help


ah now i get it, but the websocket is the same port as my adonis , which is port 3333


35%20PM im kinda loss sorry sir virk, itried to google it , then what answer i got it in the picture


then the site shut down


is there a way where my site uses normal ws which is working when i type an ip adress of the server?


Yeah, you can define the url normally.

const conn = adonis.Ws('ws://')

But if your site is on https, then I don’t think the browser will allow Websocket connection without SSL.

The reason your site shuts down, because Apache goes down. When you are defining the SSL virtual host, you need to provide the SSL certificates too.

Again, something you have read about more and have proper configuration for Apache.


sorry sir virk huhu, actually im having 6 hours solving this issue,

do i need to add those cert files on the server.js?


hi i tried to make config in sites-available and symlink to sites-enabled

i already port forward 80 to 443

but its kinda not working, are there any missing scripts?



hi @virk i think i almost got what are you referring to, i use the 443 file out of certbot then it is redirecting, but the problem is with my websocket, are there any wrong config in the screenshot ?


wss is for SSL
ws is for standard connection.

As far as I know that your Adonis server running on port 3333 is not running on HTTPS. So the first wrong thing is the Rewrite Rule.

It should be

RewriteRule ^/ws ws://localhost:3333/ws


thanks sir @virk, i also changed the websocket path in adonis to match that answer of yours, it is now working hehehe we can now proceed to our next dev phase :slight_smile: