I am trying to start a https node.js server.
I started by creating a certificate and key following this guide:
http://gaboesquivel.com/blog/2014/nodejs-https-and-ssl-certificate-for-development/
and I placed them in my /app_name/security/keys directory.
To start my https server, I have the following:
const https         = require('https'),
      fs            = require('fs');
if(app.get('env') === 'development') {
    console.log('dev env!!'); //prints correctly
    console.log('port: ' + port); //prints correctly
    const options = {
        key: fs.readFileSync('./security/keys/key.pem'),
        cert: fs.readFileSync('./security/keys/cert.pem')
    };   
    https.createServer(options, (req, res) => {
        console.log('https good to go'); //this does not print out anything
    }).listen(port);
}
When I go to https://localhost:3000, the page throws an error
This site can’t be reached
localhost unexpectedly closed the connection.
ERR_CONNECTION_CLOSED
But there's no error on the server side console. Furthermore, if i go to the regular localhost:3000, I get:
The localhost page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
Can someone help?
Thanks in advance!
---- UPDATE ----
I'm running on port 443 now. Initially I got an error:
Error: listen EACCES 0.0.0.0:443 so I ran:
sudo NODE_ENV=development nodemon app
Which did not throw any errors. However, when I went to https://localhost:443, I get:
This site can’t be reached
localhost unexpectedly closed the connection.
 
     
    