Question

How do I get my droplet to listen to port 4000 and port 27017

So my company has a webserver on port 4000 (Cloudflare) and mongodb on port 27017. I tried to do ufw allow 27017/tcp, or ufw allow 27017, ufw allow 4000, ufw allow 4000/tcp. However when I’ve done an nmap scan the ports are still closed for some reason. Why is this? What am I missing? I’ve tried to enable nginx and apache but we already have a webserver on cloudflare, so isn’t it mood point?


Submit an answer
Answer a question...

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
June 28, 2022

Hi there,

In order for you to be able to access those services externally, besides allowing the ports via your firewall, you need to make sure that they bind on 0.0.0.0 rather than 127.0.0.1.

For example, with MongoDB you can do that by following the steps here:

https://www.digitalocean.com/community/tutorials/how-to-configure-remote-access-for-mongodb-on-ubuntu-20-04

For the service that is listening on 4000, can you confirm what type of service is it?

Best,

Bobby

Hello there,

What is your problem? Your droplet has this ports open but you can’t to connect to them?

From your Droplet

Check out your open ports

  1. netstat -putan

Check out the current status of your firewall

  1. sudo ufw status verbose

From outside your Droplet

Check out your open ports

  1. nmap your_droplet_ip

If you need to check a specific port

  1. nmap -p 4000 your_droplet_ip

Hope this helps,

Sergio Turpín

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.