Question

How to receive UDP packets via a python socket in ubuntu running on digitalocean?

I’m using a simple python socket that listens on IP 0.0.0.0 via port 65333 for incoming UDP packets. To test if the script with the socket worked, two consoles were opened in the droplet and one console ran the python script with the socket and the other console send an UDP packet to the droplets official IPv4 address via netcat to port 65333.

Under these circumstances the socket receives the packet correctly, but it does not work if netcat is used with the same parameters on my laptop or another computer.

The firewall accepts all UDP packets so the packets should not be dropped.

Pinging the server is also possible from the external environment.

When I run nmap in the console on the cloud for UDP I get:

PORT STATE SERVICE

65333/udp open|filtered unknown

But when I do it on my local machine I get:

PORT STATE SERVICE

65333/udp closed unknown

So it seems like the port is both open and closed at the same time which is not possible. How do I proceed with troubleshooting from here?


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.

Accepted Answer

So I tried disabling all firewalls and checking everything once more and I still didn’t receive the UDP packets when sending from my external computer. So out of desperation, I tried out the packet sender software and when I send UDP traffic with that, I receive the traffic. So I think the problem lies with my netcat installation. Next time I will try multiple different means of communication. :D Anyway, it might have been the port was also an issue, so thanks a lot for your help Bobby. ^_^

Bobby Iliev
Site Moderator
Site Moderator badge
April 13, 2022

Hello,

I could suggest trying out with a different port as port 65333 is a dynamic port, or also called private port.

The range of the dynamic ports is from 49152 to 65535. So I could suggest choosing a port lower than 49152.

This could explain why you can access the port via the Droplet itself locally, but it doesn’t work over the public network.

Let me know how it goes!

Best,

Bobby

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.