title: I want to run a websocket server with mongoose how do I solve the error?
body: <p><a href="https://github.com/cesanta/mongoose/blob/master/examples/websocket-server/main.c" rel="nofollow noreferrer">https://github.com/cesanta/mongoose/blob/master/examples/websocket-server/main.c</a></p>
  <pre><code>#include &quot;mongoose.h&quot;
  
  static const char *s_listen_on = &quot;ws://localhost:80020&quot;;
  static const char *s_web_root = &quot;.&quot;;
  
  // This RESTful server implements the following endpoints:
  //   /websocket - upgrade to Websocket, and implement websocket echo server
  //   /api/rest - respond with JSON string {&quot;result&quot;: 123}
  //   any other URI serves static files from s_web_root
  static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
    if (ev == MG_EV_OPEN) {
      // c-&gt;is_hexdumping = 1;
    } else if (ev == MG_EV_HTTP_MSG) {
      struct mg_http_message *hm = (struct mg_http_message *) ev_data;
      if (mg_http_match_uri(hm, &quot;/websocket&quot;)) {
        // Upgrade to websocket. From now on, a connection is a full-duplex
        // Websocket connection, which will receive MG_EV_WS_MSG events.
        mg_ws_upgrade(c, hm, NULL);
      } else if (mg_http_match_uri(hm, &quot;/rest&quot;)) {
        // Serve REST response
        mg_http_reply(c, 200, &quot;&quot;, &quot;{\&quot;result\&quot;: %d}\n&quot;, 123);
      } else {
        // Serve static files
        struct mg_http_serve_opts opts = {.root_dir = s_web_root};
        mg_http_serve_dir(c, ev_data, &amp;opts);
      }
    } else if (ev == MG_EV_WS_MSG) {
      // Got websocket frame. Received data is wm-&gt;data. Echo it back!
      struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
      mg_ws_send(c, wm-&gt;data.ptr, wm-&gt;data.len, WEBSOCKET_OP_TEXT);
    }
    (void) fn_data;
  }
  
  int main(void) {
    struct mg_mgr mgr;  // Event manager
    mg_mgr_init(&amp;mgr);  // Initialise event manager
    printf(&quot;Starting WS listener on %s/websocket\n&quot;, s_listen_on);
    mg_http_listen(&amp;mgr, s_listen_on, fn, NULL);  // Create HTTP listener
    for (;;) mg_mgr_poll(&amp;mgr, 1000);             // Infinite event loop
    mg_mgr_free(&amp;mgr);
    return 0;
  }
  </code></pre>
  <p>I want to create a websocket server, but I am getting an error while running this project.
  I tried on different ports but the result did not change.</p>
  <p>Error is:
  mongoose.c:2774:mg_listen    Failed: ws://localhost:80020, errno 0
  <a href="https://i.stack.imgur.com/y7bSu.png" rel="nofollow noreferrer">Failed</a></p>