How to access minecraft server only on a specific port?

Posted February 18, 2020 1.8k views

I’ve changed the minecraft server’s port to a different one and created an SRV and A record for it, but the minecraft server still works when I go to “” and I only want it to work when I go on “” or “”.

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.

Submit an Answer
1 answer

Hi @usernameunlocked,

You’ll first need to edit the configuration file of your Minecraft Server and set the port to be 0000, I think by default it’s something like 25026.

As soon as you’ve done that, you’ll need to restart your Minecraft server. To test everything is actually working type in

netstat -tulpen | grep 0000

If you see the instance running then everything is okay. Now you’ll need to edit your firewall configuration.

If you are using UFW, you can enable the port by executing the following command

sudo ufw allow 0000/tcp

To actually check if it’s enabled or not, type in

sudo ufw status numbered


  • I’m experiencing a similar problem on a different port however I don’t have UFW, In fact I haven’t installed anything at all.

    Should I actually install UFW or use anything else?

    • There is no need for that or at least it’s not mandatory. You can use IPTables directly instead.

      To allow all incoming connections on a specific port, you’ll just need to type in this 1 command:

      iptables -A INPUT -i eth0 -p tcp -m tcp --dport XXXX -j ACCEPT

      Please note the XXXX in the command should be replaced with the port you want.