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 the file with a text editor.
  1. Find the server-port line:
server.properties file with server-port 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 in 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 firewall. In this section, we will go over the process on three operating systems – Windows, macOS, and Linux.

Firewall Management on Windows

  1. Open Windows Defender Firewall with Advanced Security.
Windows Defender Firewall desktop app, where users can access advanced settings of Windows Defender
  1. Click on Inbound Rules and select New Rule.
Windows Defender view with "new rule" option highlighted
  1. Choose Port and click Next.
Rule creation 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.
Firewall rule applied to TCP and to default Minecraft server port
  1. Select Allow connection and click the Next button until the final step. Before clicking Finish, give your rule a name, like in this example:
Last step for Windows Firewall rule creation. This will allow incoming traffic to user's Minecraft server
  1. After you have created the rule, make a new one with the same configuration, just for UDP.

Firewall Management on macOS

  1. Go to System Preferences and select Security & Privacy.
Apple system preferences menu with security & privacy button highlighted
  1. Choose Firewall and click on the Firewall Options button.
Firewall menu inside of security and privacy on MacOS with "firewall options" button highlighted

If the option is grayed out, select the lock icon on the lower-left corner to unlock Firewall Options.

  1. Click Add, find the installed Java application, and confirm the selection. Make sure that the Allow incoming connections option is checked.

Firewall Management on Linux

Unlike Windows or Mac, Linux comes with a more complex 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 allowed, proceed to create a port forward rule on your router. Even though each router has a different interface, the steps will be similar.

  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 the 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 on the Default gateway line.

Command prompt ipconfig command output showing the default router's address

To set up a static IP address, press Windows + R again and enter ncpa.cpl. Right-click your network interface, select Properties, locate Internet Protocol Version 4 (TCP/IP), and select Properties again:

Ethernet properties menu for Windows operating system with "properties" button highlighted

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

A IPv4 properties window with "use the following IP address" section highlighted and 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 Preferences and select Network.
System Preferences window for macOS with "network" button highlighted
  1. Find the network you’re using and click Advanced.
Network connection window for macOS with "advanced" button highlighted
  1. Navigate to the TCP/IP tab. The Router line will contain the router’s IP address.
Network window for macOS with router's IP address highlighted

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 zero to the router IP.

Configuration for static IP address on macOS

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 18.04 configuration can be accessed by pasting this command into 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 into your browser’s address bar and press Enter. A login page will appear.

A login form when connecting to a router page.

It will ask for a username and password. If you are unsure where to find them, check the stickers on your router. Another option is to Google the router’s name and model number along with 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 this tutorial, we’ll use a D-Link router. Its interface for port forwarding looks like this:

Router page for D-Link

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 the configuration for both TCP and UDP ports.

Port forwarding configuration under "advanced" tab in D-link

Once done, save the 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 on the server console and reinitialize the server.

A running Minecraft server with /stop command typed out

Once the server has restarted, open Google and enter “What’s my IP”. This will show your public IP address that you will need to share with the people you want to play with.

Google result for public IP, this address is set by your internet service provider

Expert Tip

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

Editor

Egidijus N.

Head of Cyber Security

Now players will be able to join the 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.

Connection to Minecraft server window with a server address highlighted

Alternatively, just enter the IP address.

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.