Skip links
Change the Port for Uptime Kuma

A Step-by-Step Guide: How to Change the Port for Uptime Kuma

Changing the port for Uptime Kuma can be really useful for a few reasons. By default, Uptime Kuma usually runs on something called port 3001. That might sound a bit technical, but it’s like a special door that Uptime Kuma uses to communicate. 

It’s a good idea to move it behind another tool like Nginx or Apache, which are like guards that keep everything safe when it’s out on the internet.

Reasons Why It’s A Good Idea To Change This Port

1. Enhancing security

When you change the port, it’s like giving Uptime Kuma a secret hiding place. This makes it tough for bad people who want to do harm to find it and cause problems. Changing the port can also stop them from looking for weak spots in Uptime Kuma.

2. Customization

Changing the port can make your life easier. Think of it like renaming your favorite video game character so you can remember it better. For Uptime Kuma, it means you can use a port number that’s easy to remember, like 80 or 443. This makes it a breeze to open Uptime Kuma in a regular web browser.

3. Server management

Changing the port is a great way to keep things organized. Imagine you have a bunch of different things running on your computer, like games, apps, and Uptime Kuma. By using different port numbers for each, you make sure they don’t get mixed up or fight with each other.

Prerequisites for Changing Uptime Kuma’s Port

Before you start changing the port for Uptime Kuma, you’ll need a few things. Let’s go through them step by step:

1. Uptime Kuma Needs to Be Installed and Running

You must have Uptime Kuma already set up and working on your server. It’s like making sure you have all the ingredients before baking a cake.

2. Basic Knowledge of Server Administration

You should also have some basic knowledge about how servers work. Think of it as knowing the rules of a game before you play it.

3. Access to Your Server

This is like having the keys to your house. You need access to the server where Uptime Kuma is installed. It’s like needing the key to your front door to get inside your house.

Read also: Checkmk vs. Uptime Kuma: Which Is The Right Monitoring Tool?

Changing The Uptime Kuma Port

Changing the port for Uptime Kuma can be done in a few different ways. Let’s explore these methods in detail:

1. Environment Variables

This is one way to set the port for Uptime Kuma. You can think of environment variables as instructions that tell Uptime Kuma which port to use. It’s like giving Uptime Kuma a secret code. 

For example, you can set the UPTIME_KUMA_PORT environment variable to the port number you want. So, if you want to use port 12345, you would set it like this: UPTIME_KUMA_PORT=12345.

2. Command Line Arguments

Imagine you are giving Uptime Kuma a special command when you start it. You can do this using what’s called a command line argument. It’s like telling Uptime Kuma directly which port to use. 

For instance, you can start the server by typing a command like this: “node server/server.js –port=12345”. This tells Uptime Kuma to use port 12345.

3. Editing the server.js File

Now, this method is a bit like opening up a book and changing a page. You can open the server.js file located in the Uptime Kuma directory. Inside this file, there’s a number that’s usually set to “3001,” which is the default port. 

You can change this number to the port you want. However, there’s a catch. If you update Uptime Kuma, this change might get erased, so it’s not the best way to do it.

4. WebSocket and Headers

Uptime Kuma is a bit special because it’s based on something called WebSocket. To make this work properly, you need to add two more special instructions called headers. 

These headers are called “Upgrade” and “Connection.” They’re like additional notes you give to Uptime Kuma so it can handle WebSocket correctly. If you want to know more about this, you can check out the Uptime Kuma wiki for detailed information.

To sum it up, the best and safest ways to change the port for Uptime Kuma are by using environment variables or command line arguments. They are like clear and easy instructions that Uptime Kuma can follow without any problems. 

Editing the server.js file is possible, but it might get undone when you update Uptime Kuma, so it’s not the recommended method. And don’t forget about those extra headers if you’re dealing with WebSocket; they are essential for it to work smoothly.

Read also: Monitoring Discord Bot Uptime Made Easy with Uptime Kuma

Testing the Port Change

How to Access Uptime Kuma on a New Port

To access Uptime Kuma through a newly set port, follow these steps: First, type this web address into your browser: http://YOUR-IP:PORT. In this address, “YOUR-IP” should be replaced with the IP address of the server where Uptime Kuma is running. Meanwhile, “PORT” should be the number of the port you’ve chosen.

This link will take you to your Uptime Kuma dashboard.

Confirming the Successful Port Change

After changing the port, it’s essential to make sure everything went smoothly. To do this, try accessing Uptime Kuma with the new port using the link mentioned earlier. If you can open Uptime Kuma without any trouble, your port change was successful. Also, you might want to review the Uptime Kuma logs for any errors connected to the port.

Troubleshooting Common Issues

When you change Uptime Kuma’s port, some common problems might pop up. Here are these issues and ways to deal with them:

1. Uptime Kuma Can’t Be Reached on the New Port

Ensure that no other service is using the port you selected. You can check this by running the command sudo lsof -i :PORT, where “PORT” should be replaced with your chosen port number. If something else is using the port, you can either stop that service or pick a different port. Additionally, check your server’s firewall settings to make sure it’s not blocking the new port.

2.Uptime Kuma Reports False Downtime

If Uptime Kuma tells you there’s downtime when there isn’t, it could be due to monitoring HTTP services on non-standard ports. Uptime Kuma sometimes follows HTTP redirects and might lose track of the port number. To fix this, consider using DNS resolution or specify the IP/HOST when you create a monitor.

3. Uptime Kuma Monitors the Wrong Service

If Uptime Kuma is watching the wrong service, double-check that you’ve given the right service URL and port number when creating the monitor. Also, don’t forget to peek at the Uptime Kuma logs for any issues connected to the monitor.

Security Considerations

Security is crucial when setting up your Uptime Kuma instance. Let’s delve into why and how to make sure your setup is safe.

Why a Secure Port Matters

Selecting a secure port is your first line of defense. Imagine it as a shield for your Uptime Kuma instance, protecting it from nasty attacks. Uptime Kuma usually hangs out on port 3001. This might seem like a secret hideout for it, as it’s not a famous port. Hackers prefer to target well-known ports like 80, 443, or 8080. So, it’s a wise move to choose an uncommon port number. And, don’t forget to set up your server’s firewall to only allow traffic on this chosen port.

Best Practices for Keeping Things Safe

Here are some tips to keep your Uptime Kuma instance extra safe:

1. Use HTTPS: Think of this as a special lock for your communication. Install an SSL certificate on your Uptime Kuma instance. This fancy certificate encrypts the chat between Uptime Kuma and the websites it’s keeping an eye on. It’s like making sure that the secret messages stay secret.

2. Strong Passwords: You know how you need a secret code to enter a club? Well, your Uptime Kuma needs one too. Make sure it’s a strong, unique code, not the default one. This way, you’re the only one invited to the party.

3. Two-Factor Authentication (2FA): 2FA is like having a secret handshake. It adds an extra layer of security. Even if someone sneaks in with your password, they won’t get very far without the secret handshake.

4. Stay Updated: Like your favorite games or apps, Uptime Kuma needs updates too. Regularly update it to the newest version. This way, you fix any holes that hackers might try to sneak through.

5. Separate Server: Sometimes, it’s better not to put all your eggs in one basket. Running Uptime Kuma on a different server is like that. It makes sure everything runs smoothly. If one thing goes bad, the other keeps going. Plus, it gives you a better view of how your system is doing, both health and performance-wise.

By following these safety tips, you’ll have a happy and secure Uptime Kuma instance, free from pesky security threats.

Read also: Uptime Kuma vs. Nagios: The Best Side-By-Side Comparison

Final Thoughts on Uptime Kuma Change Port

When changing port in Uptime Kuma you should also use something called a “reverse proxy” to make sure Uptime Kuma stays safe when it’s facing the big, wide web. 

This is like having extra security to protect against attacks, just like a superhero. It also gives you cool features like SSL encryption to keep everything super safe. So, remember, it’s not just about changing the port, but also using a reverse proxy to make Uptime Kuma super secure!