Two common errors while starting Apache server on Linux

  • HOME
  • >
  • >
  • Two common errors while starting Apache server on Linux
Last Updated: 

👉 This post was initially written in 2007 and referred to specific software versions. When troubleshooting your system, always consider which version and environment you are using.

Remember that the correct way to start the apache server is to use the apachectl command.

apachectl stop
apachectl start
apachectl graceful

You can also check your configuration files using apachectl configtest.

Address Already in Use

(98)Address already in use: make_sock: could not bind to address
no listening sockets available, shutting down

This is caused by one or more processes running on the 443 (secure socket) port. You can get all the process ID's that are running on this port with the command fuser or a more classical ps auxww with a less readable format.

[me@host ~]$ fuser 443/tcp
443/tcp: 7977 6815 9819 35217
# Now you just have to do a **kill** on those process.
[me@host ~]$ kill -9 7977 6815 9819 35217
# Or in a single line:
[me@host ~]$ kill -9 $(fuser 443/tcp 2>/dev/null)

No space left on device

(28)No space left on device: Couldn't create accept lock
# or
(28)No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed

When you check your storage, you find out that you have plenty of space still available. So, what is going on? The problem comes from apache that was not shutdown properly and left a lot of semaphore-arrays behind. Semaphore arrays are use for interprocess communication (ipc). So, here comes the ipcs command. ipcs provides information on the ipc facilities for which the calling process has read acccess.

[me@host ~]$ ipcs -s | grep www-data
0x00000000 163840 www-data 600 1  
0x00000000 196609 www-data 600 1  
0x00000000 229378 www-data 600 1

Before restarting your apache you have to remove all this semaphore arrays by using the ipcrm command. ipcrm removes a message queue, semaphore set or shared memory id.

[me@host ~]$ ipcs -s | grep www-data | perl -e "while () { @a=split(/\s+/); print \`ipcrm sem $a[1]\`}"
Related linux posts that you may like...
The Complete How To Guide of Bash Functions
Learn how to write shell scripts with bash functions. This guide includes examples and best practices on how to define, call, and debug functions in bash.
How To Create Simple Menu with the Shell Select Loop?
The select loop is not a regular shell loop. It can be used in Bash to generate a simple menu from which a user can select numbered options.
What is the Right Way to do Bash Loops?
Looping over a list of numbers or words is a building block in shell scripts. Learn how to write Bash loops, including for loop, while loop, and until loop.
What is the Best Way to Count Files in a Directory?
Learn how to count the number of files in a directory using the Linux command line ls, find, and a native bash shell solution with globs and arrays.