Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6246873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:46:09+00:00 2026-05-24T12:46:09+00:00

When using https.request with node.js v04.7, I get the following error: Error: socket hang

  • 0

When using https.request with node.js v04.7, I get the following error:

Error: socket hang up
    at CleartextStream.<anonymous> (http.js:1272:45)
    at CleartextStream.emit (events.js:61:17)
    at Array.<anonymous> (tls.js:617:22)
    at EventEmitter._tickCallback (node.js:126:26)

Simplified code that will generate the error:

var https = require('https')
  , fs    = require('fs')

var options = {
  host: 'localhost'
, port: 8000
, key: fs.readFileSync('../../test-key.pem')
, cert: fs.readFileSync('../../test-cert.pem')
}

// Set up server and start listening
https.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'})
  res.end('success')
}).listen(options.port, options.host)

// Wait a second to let the server start up
setTimeout(function() {
  var clientRequest = https.request(options, function(res) {
    res.on('data', function (chunk) {
      console.log('Called')
    })
  })

  clientRequest.write('')
  clientRequest.end()
}, 1000)

I get the error even with the server and client running on different node instances and have tested with port 8000, 3000, and 443 and with and without the SSL certificates. I do have libssl and libssl-dev on my Ubuntu machine.

Any ideas on what could be the cause?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:46:10+00:00Added an answer on May 24, 2026 at 12:46 pm

    In

    https.createServer(function (req, res) {

    you are missing options when you create the server, should be:

    https.createServer(options, function (req, res) {

    with your key and cert inside

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object.
I am using node-mysql module ( https://github.com/felixge/node-mysql ) OR ( http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/ ) . Is
Is it possible to do a HTTP Head request solely using an XMLHTTPRequest in
I need to execute a http web request from Plesk's Task Scheduler (using shared
A WebDAV library I'm using is issuing this request MKCOL /collection HTTP/1.1 To which
I get security exception when using System.Net.WebClient to do HTTP requests, which is due
I'm using nodejs to create a simple proxy server that logs http and https
I'm using async module (see https://github.com/caolan/async ) for Node.js and my question is... Why
I have written a http server using node js var sys = require(sys), http
I just installed Ubuntu 10.10 server with NodeJS 0.4.6 using this guide: http://www.codediesel.com/linux/installing-node-js-on-ubuntu-10-04/ on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.