Running a nodejs application

July 6, 2017 127 views
Node.js Nginx Ubuntu 16.04

Hi there,

I am on a Ubuntu 16.04 droplet running nginx, php7.1-fpm and trying to run a nodejs application over ssl.

To install Nodejs I followed this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

I cannot even get this line to work:

curl http://localhost:8080

I get:

curl: (7) Failed to connect to localhost port 8080: Connection refused

I have open port 8080 on UFW.

What else can I do?

4 Answers

Hi @stephgiguere

When you execute the hello.js script in the console, you need to open a new console window and login again and then run the curl http://localhost:8080.

And you should remove that firewall rule again.

@stephgiguere

Refer to this tutorial to run your nodejs in background.

To run it over ssl you can use nginx reverse proxy.

Hope this helps.

by Jim Cassidy
Use these instructions to setup an Ubuntu server to run Node.js applications, including apps based on Express, Geddy, or Sails. This will help you avoid some security mistakes and will provide some surprising benefits.

@hansen @Mohsen47
Thank you, gave a shot to both still not working, I guess there is something funky going on with my server.
have uninstalled and reinstalled with many tutorials and can't ever get a stupid hello world to show up in nodejs, so sad.

  • @stephgiguere

    I've followed that tutorial with a lot of other people, so not sure why it isn't working for you. The only thing special about that tutorial is the opening of an extra console window, when you do the curl-test.

    So when you execute the ./hello.js what happens ?

@hansen
I get :

curl: (7) Failed to connect to localhost port 8080: Connection refused

Have another answer? Share your knowledge.