For some odd reason, I cannot connect to my node-app externally, I can’t figure why, please send help! :D
root@gitty:~/gitty.me# node server/ &
[1] 6585
root@gitty:~/gitty.me# nListening on { address: '0.0.0.0', family: 'IPv4', port: 3000 }
root@gitty:~/gitty.me# netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3194/nginx -g daemo
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1398/sshd
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 6585/node
Ps. Nginx works, but node doesn’t :c
Sincerely, Mads Cordes
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!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
@Mobilpadde
Posting this as a separate reply since it’ll be a little lengthy :-).
…
The default server block for NGINX will be located at:
The above file, with NGINX running, is why you’ll see some sort of response to incoming requests after pointing your domain to the IP of the Droplet.
You’ll need to modify that file to suit your specific needs and proxy requests to your NodeJS app. To start, I’d recommend wiping that file clean.
To do that, we can run:
That’ll result in an empty file we can now setup to respond to requests for your application. So let’s go ahead and edit it.
Within that file, paste in:
You’ll need to modify:
…and replace
domain.com
with your actual domain name.Once you’ve done that, save the file and restart NGINX using:
That should get things working for you without having to attach the port to the URL.
@Mobilpadde
We’d need to take a look at the server block you configured for NGINX and your NodeJS app.
Without a properly configured server block that proxies requests on port 80 to 3000, the only way to access your application from the browser will be by appending the port to the end of the URL or IP.