Question

Nodejs not allowing access to https://mydomain.com:3000 refusal

Posted May 25, 2017 14.5k views
Server OptimizationUbuntu 16.04

Hello community,

I had a pre server install nodejs and npm after. I hand installed a lamp server on it. But I would like to run apps which require node.js

Would like to access to https://peopleandchat.org:3000 it will not load anything.

Any ideas how I can get this to work correctly? using socket.IO chat.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
3 answers

@peopleandchat

It really depends on what IP you’re using to start the server for the app.

If you use localhost or 127.0.0.1, you won’t be able to access the app via port using your domain as only local access is being permitted.

You’d need to use 0.0.0.0 as the IP, or configure Apache to proxy all requests on port 80 to the local address and port your running the application on.

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
  • @peopleandchat

    The last part “Set Up Nginx as a Reverse Proxy Server” would mean that all visitors would talk to Nginx, which would then connect to Node.js in the backend.

    This can be done with Apache as well, if that’s what you’re using. DigitalOcean doesn’t have a tutorial specifically for that, but there’s a tutorial here, which uses port 8080, so you just have to use port 3000 instead:
    www.codingtricks.biz/run-nodejs-application-apache/

Look very closely at jtittle1 ’s answer. I wasted a whole day on this because my ports were misconfigured between localhost, ‘127.0.0.1’ and not having any host in my express js server. Instead of

app.listen(port, () =>

it should be

app.listen(port, hostname, ()=>
Submit an Answer