Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I can stop it using

/etc/init.d/apache2 stop

But when I want to start it again using:

/etc/init.d/apache2 start

I get this error:

Starting web server apache2                                                  /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
                                                                         [fail]
share|improve this question

4 Answers 4

up vote 16 down vote accepted

Some words about the errors you get which hopefully will save you from similar situations in future.

In Linux ports from 0 to 1024 are reserved for system use. This means that in order to use one, you must have the authority to change - access basic system settings. The root user has such privileges and can actually use a port from the range 0 - 1024.

In your problem as you can see, the system through Apache2 response indicates the root of the problem ([...]could not bind to address blah blah 80):

(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80

When the Apache2 http daemon starts, it tries to bind the 80 port as it is the default port for use in HTTP see, which is a port within the system assigned ports and as such it can only be accessed by root.

You executed the start command as a typical user without root privileges and led to failure to do so.

In simple words:

You

Hi Apache2 i am Kongthap and i am telling you to start (/etc/init.d/apache2 star)

Apache2

Ok i am starting (Starting web server apache2)

System please give me port 80 to use and listen for connections

System

OK one moment to check

ahh sorry Apache2 but i cannot let you run at 80 port, it is for personal use

and you do not have the correct privileges to bind it.(Operation not permitted)

Apache2

Ohh, Kongthap i failed to start, the system did not let me do it ((13)Permission denied:[...])

Conclusion

There are mainly two solutions to this problem:

1) Run the Apache2 http daemon with root privileges using sudo

sudo service apache2 start prefered method

or

sudo /etc/init.d/apache2 start

2) Change the default port from 80 to something greater than 1024, say 2000, 2500, 9000, etc. A typical port to run when in such situation is 8080

sudo vi /etc/apache2/ports.conf

look for or if not there add:

Listen 8080

or any other port of your choice such as port > 1024 and the selected port is not used by another process.

share|improve this answer
1  
Really excellent explanation!!! –  Kongthap Aug 28 '13 at 9:52
    
+1 for the excellent screenplay –  Kevin Chen Jan 16 at 2:34
    
Great explanation, understood well! –  TechyTimo Sep 6 at 12:05
    
Great explanation. Why is using service the preferred method? –  Trengot Oct 15 at 20:34
    
They are Upstart directives, check this question and answers askubuntu.com/q/19320/12218 and for more detailed view check the upstart cookbook upstart.ubuntu.com/cookbook. Keep in mind these refer to the services (daemon) handling (when and how to start-stop) this question and my answer also tackles the permission problems. –  Stef K Oct 15 at 23:49

Following are the commands to start/stop/restart apache server:

  • To start:

    sudo /etc/init.d/apache2 start
    
  • To stop:

    sudo /etc/init.d/apache2 stop
    
  • To restart:

    sudo /etc/init.d/apache2 restart
    
share|improve this answer
    
After restart the computer, it seems ok with all commands you suggested but I got this message during restarting... Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName –  Kongthap Aug 28 '13 at 6:50
1  
@Kongthap: that's not an error. I'm sure the web is full of explanation for that message. –  Andrea Corbellini Aug 28 '13 at 7:09
    
Yes, @AndreaCorbellini is correct. It is not an error, it says because your ip does not have any Fully Qualified Domain Name for example mail.google.com. –  Saurav Kumar Aug 28 '13 at 11:22

this is an selinux error at least in my case it was either change the boolean, or just disable selinux or set it for permissive with a "setenforce 0" The boolean change would require you to run "getenforce -a | grep http" look for the "allow http connect network" copy it and replace "on" where the list says "-- off"

share|improve this answer
    
Ubuntu use AppArmor not SELinux, so your answer is irrelevant to ubuntu. –  sgx1 Jan 17 at 3:25

check the selinux port context by issuing command semanage port -l | grep http

if its present in http_port_t list then it ok otherwise add your port by *semanage port -a -t http_port_t -p tcp 80*

or some thing that u want to assign

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.