The Best Way to Restart an Apache Web Server

Restart Apache on Ubuntu, RedHat, Gentoo and other Linux distros

Apache web server running under Ubuntu.


If you are hosting your website on an open source platform, it is very likely that this platform is Apache. If this is the case, and you are hosting with an Apache server, then when you're working on editing the Apache


file or another configuration file (like adding a new virtual host), you will need to restart Apache so that your changes will take effect. This may seem scary, but luckily this is very easy to do. In fact, you can do so in about one minute (not counting the time it will take to read this article to get the step by step instructions).

Getting Started

  1. To restart your Linux Apache web server, the best way is to use the


    command. This command is available on many distributions of Linux including Red Hat, Ubuntu and Gentoo. Here's how you would do this: login to your web server using SSH or telnet and make sure that your system includes the


    command. It is usually found in the


    directory, so list that directory:

    ls /etc/i* 
  2. If your server uses


    , you will get a listing of the initialization files in that specified folder. Look for




    in that folder next. If you have


    , but do not have an Apache initialization file, go to the section of this article with the heading that reads “Restarting Your Server Without Init.d”, otherwise you may continue.

  3. If you have


    and an Apache initialization file, then you can restart Apache using this command:

    /etc/init.d/apache2 reload 
  4. You may need to sudo in as the root user to run this command

The Reload Option

Using the


option is the best way to restart your Apache server, as it keeps the server running (the process isn't killed and restarted). Instead, it just reloads the


file, which is usually all you want to do in this instance anyway. If the reload option does not work for you, you can also try to use the following commands instead:

  1. /etc/init.d/apache2 restart

    This command kills the server process and then restarts it.

  2. /etc/init.d/apache2 stop

    This command kills the server process.

  3. /etc/init.d/apache2 start

    This command starts the server.

  4. This last command will throw an error message if the server is already running.

Restarting Your Server Without Init.d

OK, so this is where we asked you skip to if your server doesn't have


 . If this is you, don't despair, you can still restart your server. You just have to do it manually with the command


Here are the steps for this scenario:

  1. Login to your web server machine using SSH or telnet

  2. Run the apache control program:

    apachectl graceful 
  3. You may need to sudo in as the root user to run this command.


apachectl graceful

command tells Apache that you want to restart the server gracefully without aborting any open connections. It automatically checks the configuration files before initiating the restart to make sure Apache doesn't die.

  • If

    apachectl graceful

    doesn't restart your server, there are a few other things you can try.

    apachectl restart

    to restart the server. If the server is not running it is started. This command also runs a configuration test to make sure Apache won't die when it restarts.

  • apachectl stop

    To stop the Apache server.

  • apachectl start

    To start the Apache server (will throw an error message if Apache is running).

  • apachectl configtest

    To test the configuration file syntax.

  • These commands will be very helpful.

Tips for Restarting Your Apache Server

  1. init.d reload


    apachectl graceful

    both reload the configuration files and gracefully restart the web server. Any current connections are allowed to complete. This is the preferred approach and it should be what you try first.

  2. init.d restart


    apachectl restart

    reloads the configuration files and restarts. Any current connections are terminated immediately. If the server isn't running, these commands will start it up.

  3. If neither of these commands work, you should turn off your Apache server (taking it down for a short time) with the

    init.d stop


    apachectl stop


  4. Wait at least 10 seconds and then run the

    init.d start


    apachectl start
  5. If that doesn't work, you should run a check on your configuration files to make sure there isn't a problem with them by running

    apachectl graceful
  6. These steps will keep you up and running!