title: Error "ssl3_get_record:wrong version number" in node.js when making https post request
body: <p>I'm trying to make a https request to an api of my work using node.js through the following script</p>
  
  <pre class="lang-js prettyprint-override"><code>const https = require('https');
  const options = {
      hostname,
      path: fullPath,
      port: 80,
      method: 'POST',
      headers: {
          'Content-Type': 'application/json',
          'Content-Length': data.length
      }
  };
  const req = https.request(options, (res) =&gt; {
      console.log('statusCode:', res.statusCode);
      res.on('data', chunk =&gt; console.log('chunk:', chunk));
  });
  req.on('error', error =&gt; {
      console.log('Failed!');
      console.log(error);
  });
  req.write(data);
  req.end();
  </code></pre>
  
  <p>And as a response i get</p>
  
  <pre><code>Failed!
  Error: write EPROTO 6772:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
  
      at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:87:16) {
    errno: 'EPROTO',
    code: 'EPROTO',
    syscall: 'write'
  }
  </code></pre>
  
  <p>I made this request on a browser using jQuery and it worked</p>
  
  <pre><code>$.post({
      url, data,
      success: res =&gt; console.log(res),
  });
  </code></pre>
  
  <p>I tryed to use the header X-SSL-PROTOCOL with no success.
  The url and data are hidden because they are confidential, but they are the same in the jQuery example and in node.js.</p>