How to Port Forward a Minecraft Server on Linux, Windows, and macOS

How to Port Forward a Minecraft Server on Linux, Windows, and macOS

Creating your own Minecraft world on a local server can be exciting. However, it will only be visible to you, and playing alone can become tedious after a while.

With the help of port forwarding, you can provide a modded Minecraft server for anyone to connect and play.

This tutorial will show you how to port forward a server on Windows, macOS, and Linux and discuss the required configuration for this process.

What Is Port Forwarding?

If a user has a game server running locally on their machine and wants to play together with friends, connecting via an internal IP address, like 192.168.0.1, won’t work as it is a local IP address.

Port forwarding allows remote computers to connect your router and local network by using specific TCP and UDP ports. Usually, the port forwarding feature is available on most routers and can be accessed by logging in via the default router gateway.

How to Port Forward Minecraft?

To make a Minecraft server visible publicly, you will need to find the default server port, allow it through a firewall, and tinker with your router configuration.

Important! Before using the port forward feature, you should set up a Minecraft server.

Step 1 – Set the Port on Minecraft Configuration

  1. Open the Minecraft server directory and locate the server.properties file.
Windows local Minecraft installation folder in File Explorer with server.properties file highlighted
  1. Right-click on it and open it with a text editor.
  1. Find the server-port line.
server.properties file with server-port line highlighted

Here are the default port numbers for Minecraft:

  • 25565 – for Java Edition.
  • 19132-19133 – TCP and UDP ports for Bedrock.

Users can change the port by changing the server-port value to any within the range from 1 to 65535, although we recommend sticking with the default one.

Step 2 – Allow the Port on Your Firewall

To ensure that the server works correctly, you will need to allow the Minecraft port number via your system’s firewall.

In this section, we will go over the process for Windows, macOS, and Linux.

Firewall Management on Windows

  1. Open Windows Defender Firewall with Advanced Security.
Windows Defender Firewall application is shown, a built-in Windows tool that allows users to access advanced settings of Windows Defender
  1. Click on Inbound Rules and select New Rule.
  1. Choose Port and click Next.
New Inbound Rule selection window with the Port option selected
  1. Select TCP, and enter the Minecraft port number. In this case, it’s 25565. Once done, click Next.
A firewall rule applied to TCP, and the default Minecraft server port
  1. Select Allow connection and keep clicking Next until you reach the final step. Before hitting Finish, don’t forget to give your rule a name.
Giving a name to a new firewall rule, finally directing incoming traffic to the user's Minecraft server
  1. After you have created the rule, make a new one using the same configuration, but this time for UDP.

Firewall Management on macOS

  1. Go to System Settings and select Network.
System Preferences on macOS with Network button highlighted
  1. Choose Firewall and click Options.
  1. Click the Add button, find the installed Java application, and confirm the selection. Make sure that the Allow incoming connections option is selected. Hit OK.

Firewall Management on Linux

Unlike Windows or Mac, Linux is equipped with a more sophisticated firewall. We recommend checking out our tutorial on how to configure your Ubuntu firewall.

Step 3 – Forward the Port on the Router

With the firewall set up and incoming network requests taken care of, proceed to create a port forward rule on your router. Even though each router has a different interface, the steps should be nearly identical.

  1. Find your default gateway IP address. It will be used to log in to the router.
  2. Set up a static IP address.
  3. Open the port forwarding settings.
  4. Specify which TCP and UDP ports to forward.

Finding Your Router Address and Setting up a Static IP on Windows

Press Windows+R and enter CMD to open the command prompt. Run the following command:

ipconfig

The router’s IP address will be shown next to the Default Gateway line.

Command Prompt ipconfig command output showing router's Default  Gateway

To set up a static IP address, press Windows+R again and enter ncpa.cpl.

Right-click your network connection, select Properties, locate Internet Protocol Version 4 (TCP/IP), and hit Properties again:

Ethernet Properties on Windows with TCP/IPv4 entry highlighted

Specify the preferred static IP address, subnet mask (255.255.255.0), and the router IP you acquired earlier.

A TCP/IPv4 Properties window with Use the following IP address section highlighted and new IP addresses added

Once done, click OK to save the changes.

Finding the Router Address and Setting up a Static IP on macOS

  1. Go to System Settings and select Network.
  1. Find the network you’re using and click Details.
  1. Go to the TCP/IP tab. The Router line will contain your router’s IP address.
Network TCP/IP details shown in System Settings on macOS

Alternatively, open Terminal and use the following command to check the router IP address:

netstat -nr|grep default

To set up a static local IP address, go back to the TCP/IP section, choose Using DHCP with manual address, and specify the IP you would like to use. We recommend adding a 0 as the router IP.

Using DHCP with manual address option selected

Click OK to save the changes.

Finding the Router Address and Setting up a Static IP on Linux

To check the router IP on Linux-based systems, open Terminal and enter the following command:

route -n | grep "^0.0.0.0" | cut -d ' ' -f 10

To set up a static IP, you will need to edit the primary network configuration file. For example, the Ubuntu 22.04 configuration can be accessed by pasting this command into the Terminal and pressing Enter:

sudo nano /etc/netplan/01-netcfg.yaml

Here’s an example configuration where gateway4 is your router IP, and addresses refers to your preferred static IPv4 address:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
ens33:
dhcp4: no
dhcp6: no
addresses: [192.168.2.10/24]
gateway4: 192.168.2.1
nameservers:
addresses: [1.1.1.1,1.0.0.1]

Once done, save the changes made to the 01-netcfg.yaml file.

Logging in to the Router

Paste the router IP address to your web browser’s address bar and press Enter. A login pop-up will appear.

A login pop-up when trying to access the router page

You will be asked for a username and password. If you are unsure where to find them, try checking the stickers on the bottom of your router.

Another option is to Google the router’s name and model number along with related keywords like default login credentials.

Expert Tip

If your router is still using the factory default credentials, change them immediately, as anyone could access your network.

Editor

Egidijus N.

Head of Cyber Security

Once logged in, look for options related to virtual server or port forwarding. In our example, we’ll use a D-Link router.

Internet router/modem configuration panel for D-Link network equipment with Advanced tab selected

Check the Enabled option, give the forwarding rule a name, specify the local static IP address you’ve set previously, and enter the Minecraft server port. In this case, it’s 25565.

Don’t forget to apply these configurations for both TCP and UDP ports.

Setting up port forwarding in the internet router/modem configuration panel for D-Link network equipment with the Advanced tab selected

Once done, save your changes.

Pro Tip

If you are still unsure about the exact port forwarding procedure for your specific router, you can always Google the device name and look up the router’s manual.

Step 4 – Restart the Minecraft Server and Connect

For the port forwarding changes to apply, you will need to restart your Minecraft server. To do so, enter /stop in the server console and reinitialize the server.

A running Minecraft server with the /stop command typed out

Once the server has been restarted, open your preferred search engine and simply enter “what’s my ip”. You’ll be shown your public IP address that you’ll need to share with the people you wish to play with.

Expert Tip

Never share your public IP on the internet, as this can expose your physical location and make you a potential target for numerous cyber attacks.

Editor

Egidijus N.

Head of Cyber Security

Now, your players are finally able to join your server! Keep in mind that if the default server port 25565 was changed, users would need to connect using the 185.185.185.185:port syntax.

Connecting to a Minecraft server using a server address

Alternatively, enter the IP address instead.

Looking for more Minecraft tutorials?

How to Install Minecraft Mods
Best Minecraft Mods

Conclusion

Having a local Minecraft server with port forwarding allows you to play with other people, making your gameplay experience more exciting and unique.

In this tutorial, we have covered the process of port forwarding a Minecraft server on Windows, macOS, and Linux systems. We’ve also shown how to allow an application through a firewall and navigate the router interface.

Should you have any questions, feel free to leave them in the comments section below.

Author
The author

Ignas R.

Ignas takes great satisfaction in helping people tackle even the most complex technical issues. His current goal is to write easy-to-follow articles so that these issues will not happen at all. During his free time, Ignas likes to play video games and fix up things around his house.

Author
The Co-author

Paulius Zunda

Paulius is as a Content Editor who excels in creating engaging technology-based content, while his keen eye for detail ensures accuracy in all aspects of his work. In addition to his role, Paulius brings 4+ years of valuable experience to the team, with a particular knack for crafting YouTube-related content. Beyond his professional know-how, he is more than willing to talk to you about everything board games.