Question

How to unblock port 3001 and 3002

I have an app that has 3 different processes port 3000, 3001, 3002. I needed port 3000 to be mapped to port 443 (https) so the users don’t go to port 3000 to access the webpage. But the ports 3001, and 3002 are blocked. My current solution is to do open ports 3001, 3002 the same way as 3000, but that would not work as that will also map those ports to https.

Location block:

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://localhost:3000; #whatever port your app runs on
                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.

Bobby Iliev
Site Moderator
Site Moderator badge
July 5, 2021
Accepted Answer

Hi there @adityachandra,

If you do not have a firewall, in order to open the ports you would need to just start the specific services on those ports. Do you see all ports when running the following command:

netstat -plant | grep 300

If you have a firewall like UFW for example, and if you want to be able to access the ports directly, then you would need to open the ports with the following commands:

ufw allow 3001

In case that you want to add another endpoint for your application like /shop for example, you could add an additional location directive to your server block:

location /shop {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://localhost:3001; #whatever port your app runs on
                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;
        }

If the new services are going to be completely separate websites with separate domain names, then you would need to create a new server block by coping the existing config file from /etc/nginx/sites-available/your_conf and updating the details accordingly. Then you could follow the steps here on how to enable the new server block and restart Nginx:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Hope that this helps. Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel