Firewalld blocks incoming connections by default, protecting your VPS from unauthorised access. You need to open specific ports to allow legitimate traffic to reach your applications.
You will open ports in firewalld by enabling predefined services or specifying port numbers directly. This allows applications like web servers, databases and SSH connections to function whilst maintaining security.
Firewalld includes predefined service configurations for common applications. Using these services makes your firewall rules more readable and easier to manage than specifying port numbers directly.
ssh user@your-server-ip replacing user with your username and your-server-ip with your server’s IP address.firewall-cmd --get-services to display all predefined services. Look for entries matching your application, such as http and https for web servers, ssh for SSH connections, mysql and postgresql for database servers, or mongodb for MongoDB.If you find a matching service, proceed to the next section. If not, you will open the port manually by specifying its number.
You can enable access by adding either a predefined service or a specific port number. Services provide clearer configuration, whilst port numbers offer flexibility for custom applications.
sudo firewall-cmd --permanent --add-service=SERVICE replacing SERVICE with the service name, such as http or mysql. The --permanent flag ensures the rule persists after reboots.sudo firewall-cmd --permanent --add-port=3080/tcp replacing 3080 with your port number and tcp with the protocol (tcp or udp).sudo firewall-cmd --reload. This activates all permanent rules and resets any temporary runtime configurations.Your firewall now allows traffic through the specified service or port. The next section confirms your configuration is active.
After modifying firewall rules, you should confirm the correct services and ports are enabled. This prevents configuration errors that could block legitimate traffic or leave unwanted ports open.
sudo firewall-cmd --list-services to display all enabled services. Verify your service appears in the output.sudo firewall-cmd --list-ports to show manually opened ports. Confirm your port number and protocol appear correctly.If your service or port does not appear, repeat the previous section and ensure you included the --permanent flag before reloading firewalld.
You opened a port in firewalld by enabling a predefined service or specifying a port number directly. Your VPS now accepts connections on the configured port whilst maintaining security for all other services.
Review your firewall configuration regularly as you add new applications. Our guides on installing MERN stack on AlmaLinux and connecting to PostgreSQL remotely include specific port requirements. If you prefer a different firewall interface, learn how to configure UFW. Our VPS hosting gives you full control over your server’s firewall configuration.
Get scalable resources with our VPS hosting with root access and optional software.
Get VPS HostingPerfect for websites and small businesses unlimited bandwidth with cPanel hosting.
Get cPanel Hosting