Topics:

A 503 error message is generated on the server side to tell the user that the service is unavailable.

Common Error Messages

HTTP Server Error 503
503 Error
HTTP 503
Http/1.1 Service Unavailable
503 Service Unavailable
Service is unavailable
Service Unavailable - DNS Failure

503 errors can occur if a site is taken down for maintenance or if there is a server-side problem. A server-side problem doesn’t necessarily mean your server itself. It could be that the server has too many processes running or it’s trying to run inefficient programming.

Here are some common causes:

Inefficient Programming

A 503 is often due to inefficient programming. Inefficient code can slow down your server and eventually cause 503 error.

To fix the immediate problem, begin turning programs on your server off and on, one by one. If you are on a QuickServer (QS) or Virtual Private Server (VPS), you may also be able to restart Apache. See out How to Restart Apache article for more information.

Note: Keep in mind that any websites or services on your server will be unavailable while you are doing this.

To fix the overall problem, you must go through your code and look for ways to make it more efficient.

Zombie Processes

Sometimes processes aren’t properly deleted after they finish running. These processes are known as “zombie” processes. They slow down your website simply by existing.

The reason why requires some understanding of what zombie processes actually are.

When a process is done running, it leaves its process descriptor in the memory. This process descriptor signals to the process’ parent that the child process has ceased to run. If all goes correctly, the parent process will gather the child’s information and then completely remove it from memory.

Sometimes, though, the parent program isn’t programmed correctly and never gathers the child process’s information. Without the child’s information, the child will not be completely removed. This is how a zombie process is made. One or two zombie processes are fine, but the problems usually start when they begin to pile up.

While zombie processes don’t use up any system resource, they do keep their process ID (PID). On Linux servers, there is a limited number of PIDs. Usually, when a process is completely removed, its PID becomes available for a new process to use.  

The more zombie processes a server has, the fewer PIDs there are for legitimate processes. If a server runs out of PIDs due to an overabundance of zombie processes, it may generate a 503 error.

Check out HowToGeek’s explanation for more details about zombie processes on a Linux machine.

To see if you have zombie processes bogging down your server, complete the following steps:

  1. Open a terminal (Mac) or command prompt (Windows) window
  2. Type: ssh username@web-server.com and press the Enter key
    1. username.pairserver.com is the usual format of a pair Network’s web server. If you’re not sure what your web server is, log into your Account Control Center. Under Account Summary, you will see your Web Server name.
  3.  Enter your password and press the Enter key
  4. Type: ps axo pid=,stat= | awk ‘$2~/^Z/ { print }’ 
  5. Press Enter

This will display the PID and status of any zombie processes existing on your server. 

How to Fix

Once you’ve found your zombie processes, you need to get rid of them to solve the problem.

The first step to ridding yourself of zombie processes is finding the parents. You can do this by inputting the following into your shell:

pstree -s -p zombie_PID

Replace zombie_PID with the PID of the zombie child. This will show the parent of the PID you put in. Keep in mind that this also shows the parents of the parent, but the parent you are looking for is will be directly next to the zombie child.

For example:

init(1)---httpd(27117)---httpd(19531)---php5.cgi(19646)

The httpd next to php5.cgi would be the parent you are looking for.

If you find that many of your zombie processes have the same parent, then that program most likely has a bug that is keeping it from correctly closing its child processes.

Once you have the PID of the parent, you have two options:

You can try to send a manual command to the parent process to gather the child process’ information.

Do this by :

kill -s SIGCHLD parent_PID

Replace parent_PID with the PID of the parent.

However, this will not succeed if there is an error in the parent’s programming. If this is the case, you need to close the parent process. Don’t worry, you can re-open it when you finish.

Closing the parent process will send all the child process’ to the init, the first process started when Linux starts up. init regularly performs checks for zombie processes and will wipe the zombie processes the next time it performs a check.

Close the parent by:

kill parent_PID

This command asks the process to terminate. If the process has trouble shutting down, you can force the process to close by using:

Kill -KILL parent_PID

Now, the problem may be fixed momentarily, but if you suspect the parent process has a bug that keeps it from properly closing its children processes, you may want to take steps to fix it.

If the coding is your’s, you can look through it and see if anything is keeping the parent process from gathering and cleaning its zombie children.

If the code is not yours, you should report the bug to the code’s owner.