Throw Unknown reason error while using local custom domain name to test websocket

Description of the issue:
I’m a developer, and I confirm this is a bug because I’ve tested on both chrome and firefox, all are working fine, but on brave it’s broken, the issue is that when I developed websocket in local, brave browser throw unknown errors, please check below reproduce step for detailed explanation.

How can this issue be reproduced?

  1. add local custom domain name:

edit file /System32/drivers/etc/host, add this line: test.local
  1. host websocket js client using nginx:

config nginx.conf:

server {
  listen       80;
  location / {
    alias "PATH TO INDEX.HTML/";


<!DOCTYPE html>

let socket = new WebSocket("ws://");

socket.onopen = function(e) {
  alert("[open] Connection established");
  alert("Sending to server");
  socket.send("My name is LiuYue");

socket.onmessage = function(event) {
  alert(`[message] Data received from server: ${}`);

socket.onclose = function(event) {
  if (event.wasClean) {
    alert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
  } else {
    alert('[close] Connection died');

socket.onerror = function(error) {
  alert(`[error] ${error.message}`);
  1. start websocket server using nodejs:


// Node.js WebSocket server script
const http = require('http');
const WebSocketServer = require('websocket').server;
const server = http.createServer();
const wsServer = new WebSocketServer({
    httpServer: server
wsServer.on('request', function(request) {
    const connection = request.accept(null, request.origin);
    connection.on('message', function(message) {
      console.log('Received Message:', message.utf8Data);
      connection.sendUTF('Hi this is WebSocket server!');
    connection.on('close', function(reasonCode, description) {
        console.log('Client has disconnected.');

npm install http
npm install websocket
nodejs index.js

  1. access http://test.local

Expected result:

expected: connection successful
actually happened: Data: Unknown reason, Length: N/A

Brave Version( check About Brave):
Version 1.20.97 Chromium: 88.0.4324.96 (Official Build) dev (64-bit)

Additional Information:
as I said it works fine both on firefox and chrome, but not on brave, you can refer to the screenshots:

hope brave can be more developer friendly, so I don’t need to switch back to chrome, thanks

Hi @lyhistory

Probably related to this, Improving privacy for the end user, we block localhost/ 3rd-party requests. If you host the script/html on a dev site/proper website it should get around this.

thanks, understood, but it could be much better if you provide an option to activate developer mode,
or for example, instead of giving this ‘unknown reason’ error, you may tell the user to decide whether to proceed or block it,
I believe quite of lot users are developers like me, from either traditional IT industry or blockchain community, it’s inevitable for most developers to test in local env, hope you may consider this kind of feature in the future development, thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.