I am following this tutorial for my node application. https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04 Actually I want to use root folder for angular and sub directory ‘api’ for node js API. So I’m trying to connect port 3000 for node js app. But I am getting connection refused message. This port in not in listen state. So I have followed this link. https://askubuntu.com/questions/932557/how-to-listen-new-port-ubuntu-server-from-command-line /etc/systemd/system/listen-3000.service
But still I have the same issue. My /etc/nginx/sites-available/default is,
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.ts;
server_name app.mydomain.com;
return 301 https://app.mydomain.com$request_uri;
location / {
try_files $uri $uri/ =404;
}
location /api/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
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!
Hi @kenlyle64,
So you’ve configured a reverse proxy using Nginx. That’s the first step!
It seems to me like your Application is not started/listening to the proper port.
What I’ll suggest is to start your NodeJS application on port 3000 and type in the droplet the following
netstat -tlupen
Paste the output of the command here.
Do you see port 3000 there?
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.