top of page

Step-by-Step Guide: Changing the Default Port for cockpit.service in RHEL9/Rocky9



Cockpit is a powerful web-based interface that simplifies server management tasks on Linux systems. By default, Cockpit listens on port 9090 for incoming connections. However, there may be situations where you need to configure Cockpit to listen on a different port, such as to comply with security policies or to avoid port conflicts with other applications. In this tutorial, we will guide you through the steps to configure Cockpit to listen on a custom port in RHEL (Red Hat Enterprise Linux) and Rocky Linux.

Step 1: Create a Configuration File for Cockpit Socket:

The first step is to create a configuration file to specify the custom port for Cockpit to listen on. Open a terminal and run the following command to create the necessary directory structure for Cockpit socket configuration files:

[root@siddhesh ~]# mkdir -p /etc/systemd/system/cockpit.socket.d/

Next, create a configuration file named listen.conf within the cockpit.socket.d directory. You can use any text editor to create and edit this file.

[root@siddhesh ~]# vim /etc/systemd/system/cockpit.socket.d/listen.conf

In the listen.conf file, add the following lines to specify the custom port. Replace 8080 with your desired port number:

[root@siddhesh ~]# cat /etc/systemd/system/cockpit.socket.d/listen.conf
[root@siddhesh ~]#

This configuration instructs Cockpit to listen on port 8080 for incoming connections.

Step 2: Reload Systemd Daemon:

After creating the configuration file, you need to reload the systemd daemon to apply the changes. Run the following command in the terminal:

[root@siddhesh ~]# systemctl daemon-reload

This command reloads the systemd manager configuration and updates any changes made to unit files.

Step 3: Restart Cockpit Services:

Once the systemd daemon is reloaded, you can restart the Cockpit services to apply the new configuration. Run the following commands in the terminal:

[root@siddhesh ~]# restart cockpit.socket
[root@siddhesh ~]# restart cockpit.service

These commands restart the Cockpit socket and service, ensuring that Cockpit starts listening on the custom port specified in the configuration file.

Step 4: Verify Configuration & Web Console:

To verify that Cockpit is now listening on the custom port, you can use the netstat command. Run the following command in the terminal:

[root@siddhesh ~]# netstat -antp | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      1/systemd
[root@siddhesh ~]#



In this tutorial, you learned how to configure Cockpit to listen on a custom port in RHEL and Rocky Linux. By creating a configuration file for the Cockpit socket and specifying the custom port, you can tailor Cockpit to meet your specific requirements and integrate it seamlessly into your server environment. Whether you need to comply with security policies or avoid port conflicts, configuring Cockpit to listen on a custom port provides flexibility and control over server management.

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Apr 19
Rated 4 out of 5 stars.
bottom of page