Hello! I am trying to configure Express on my Nginx server, but the terminal hangs on me after trying to run the script. I have a file in the same directory as my index.html (/var/www/html) called script.js that I am trying to run. Here is the code:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.status(200).send('ok');
});
var server = app.listen(3000, 'MY_DROPLET_IP', function () {
var port = server.address().port;
console.log('Example app listening at port %s', port);
});
module.exports = server;
When I type node script.js, “example app listening” and all that jazz comes up in the terminal, but then I can’t type anything else, and going to MY_DROPLET_IP:3000 does not display anything except a Chrome error page. Please help!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @joshcamachofl:
Hi everyone:
I fixed it using this guide.
Thank you!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.