Unable to restart Apache after changing ports

I have changed the ports Apache was running on (to setup varnish) and am now unable to restart it. I have changed the ports back to their original settings but this does not help. I am not sure what to do.

When I try and start the Apache service within virtualmin I receive the message : Failed to start service :
Starting httpd: (98)Address already in use: make_sock: could not bind to address 'IP@:80
no listening sockets available, shutting down
Unable to open logs
[FAILED] (where ip is the numerical ip address).

When running In command line I receive the same message.

All the Virtualmin servers are using Http port 80 .
Apache Webserver are all on 80 (and 443) and ‘Global configuration’ > ‘Networking and Addresses’ Ports and addresses are:
ALL: 80
ALL: 443
Addresses for name virtual servers: IP:80

I am pretty sure I have set things back the way they were originally.

Can anyone please suggest a way to get Apache working again

The error message you’re receiving would suggest that Apache is still running. You can determine that with netstat -tpln | grep :80

You can try to stop Apache gracefully using service apache2 stop (your service name might be different depending on distro), otherwise use kill -9 on the process ID from the netstat command.

Thanks for the help Locutus, it is very much appreciated.

netstat -tpln | grep :80

This doesn’t return anything ( which i presume means nothing is running)

service httpd stop
This returns “FAILED”

When I run:
service httpd status
it returns: httpd is stopped

By the way I should have mentioned I am running Centos 6.

This is very odd… If Apache fails to start because (and the error message says so) something is already listening on port 80, the netstat command should definitely have returned something. Can you paste the full output of netstat -tpln please? (Enclose shell listings in [code][/code] tags to preserve linebreaks and monospace font.)

I finally figured it out, was my error completely.

I made a note of the settings in Webmin > Servers > Apache Webserver > Global Cofiguration > Networking and Addresses so I could restore them if things went wrong but I noted them down after I had already changed the IP address ports in the virtualmin servers so there were extra Ports and addresses listed, which I thought were required.

I changed the old port numbers to new but this left the port number being listed twice, once specifically against IP and once with ALL. In retrospect this is obvious but took me all day to realise.

Thank you for you time, and sorry to have wasted it with such a trivial error.

The help Virtualmin provides really is impressive.

Glad you figured it out, and no worries, even the best admin expert has “D’oh!” moments from time to time! :smiley: