Question

Connection refused with port 3000

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;
	}

}

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

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.

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?