Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding
  1. Home
  2. Developers
  3. How to Uninstall Nginx on Ubuntu

How to Uninstall Nginx on Ubuntu

  • By Gcore
  • May 28, 2023
  • 2 min read
How to Uninstall Nginx on Ubuntu

If you’ve been using the nginx web server and decide to switch to Apache, OpenLiteSpeed, or Lighttpd, you may encounter an “Address already in use” error. This indicates that ports 80 and 443 are currently occupied by nginx. To enable the new web server to use these ports, nginx needs to be removed. This guide will show you how to delete nginx from Ubuntu.

Note: Before proceeding with the uninstallation, make sure to back up any data or configurations you don’t want to lose.

To remove nginx from Ubuntu, follow these steps:

1. Connect to your server where nginx is installed. 

2. Stop the web server by entering the following command:

sudo systemctl stop nginx

3. Uninstall the nginx package with the “purge” command. This command is preferable as it not only removes the package but also deletes its configuration files, unlike the “remove” command.

sudo apt-get purge nginx

After executing the above commands, the system will prompt you to remove any dependencies.

4. Remove any dependencies that were installed alongside nginx but are no longer required:

sudo apt-get autoremove

The terminal will display a list of all the removed dependencies.

5. (Optional) You may want to check if there are any remaining nginx-related files in the system. Common directories include “/etc/nginx/” and “/var/log/nginx/”. If these directories still exist, you can remove them manually:

sudo rm -rf /etc/nginx /var/log/nginx

6. (Optional) To verify if the web server has been completely removed, check the status of the nginx service:

sudo systemctl status nginx

If the web server has been successfully removed, you’ll see the service status set to “inactive (dead)”:

That’s it! These steps help you to uninstall nginx on your server.


Want to run Ubuntu in a virtual environment? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Ubuntu:

Choose an instance

Related articles

What's the difference between multi-cloud and hybrid cloud?

Multi-cloud and hybrid cloud represent two distinct approaches to distributed computing architecture that build upon the foundation of cloud computing to help organizations improve their IT infrastructure.Multi-cloud environments involve us

What is multi-cloud? Strategy, benefits, and best practices

Multi-cloud is a cloud usage model where an organization utilizes public cloud services from two or more cloud service providers, often combining public, private, and hybrid clouds, as well as different service models, such as Infrastructur

What is cloud migration? Benefits, strategy, and best practices

Cloud migration is the process of transferring digital assets, such as data, applications, and IT resources, from on-premises data centers to cloud platforms, including public, private, hybrid, or multi-cloud environments. Organizations can

What is a private cloud? Benefits, use cases, and implementation

A private cloud is a cloud computing environment dedicated exclusively to a single organization, providing a single-tenant infrastructure that improves security, control, and customization compared to public clouds.Private cloud environment

What is a cloud GPU? Definition, types, and benefits

A cloud GPU is a remotely rented graphics processing unit hosted in a cloud provider's data center, accessible over the internet via APIs or virtual machines. These virtualized resources allow users to access powerful computing capabilities

What is cloud networking: benefits, components, and implementation strategies

Cloud networking is the use and management of network resources, including hardware and software, hosted on public or private cloud infrastructures rather than on-premises equipment. Over 90% of enterprises are expected to adopt cloud netwo

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.