Checking that localhost is running

I am looking for something that checks if my localhost and Vagrant servers are running. I found a few code snippets but haven’t been able to get anything to work. They all seem to tell me the server is always on or always off. Any suggestions? PHP or JS or wotever…

If you vagrant ssh into the VM you can issue Linux commands to check on running processes.
Commands like top or ps. And, assuming you know the server you can always call sudo service <SERVER_SERVICE> status. (For example, service nginx status)

Thanks @ParkinT. I am a numpty . What I omitted to say, was I want to be able to tell within a web page if localhost and/or Vagrant are running. Sorry…

I am not quite understanding your requirement.
If you visit localhost and get no response the server is [definitely] not running. Otherwise you will get a response.

I suppose, you could create a page that has a redirect timeout and if the server responds it loads a new page and obsfucates that. Otherwise the timeout redirects to a “status” page that notifies you the server is not running.

I am referring to the meta tag:

<meta http-equiv="Refresh" content="5; url=http://somedomain.com/statuspage/" />
1 Like

Ha! You’ve just helped me realise that what I’m trying to do would never fly! Thanks

1 Like

I don’t understand what the thought for this is.

Going to a file served from localhost that checks to see if localhost is up and running doesn’t make sense to me.

The only scenario that I can think of is if there was an HTML with JavaScript page outside of localhost and opened from the OS “file://” that would make a request to localhost and get a success or fail.

But that seems like a lot of work to do when it would be easy to simply go to http://localhost

EDIT
I was just thinking (Danger Will Robinson, Danger) that it could be possible to have some type of shell script check the status of a service. But I’m still not seeing how such a script would be utilized.

My Windows already has an “Apache status” widget

Thanks Mitt. The idea was - emphasis on WAS as I now realise it’s not worth the bother continuing with - I have a page of web addresses (bookmarks effectively) with some sites on the www, a couple on localhost and a couple on Vagrant. I thought it would be fun/useful to see if I could indicate on the page whether localhost and Vagrant were up and running. As I say, it’s past tense now.

Which stack do you use that gives the status on the Windows task bar?

I downloaded httpd-2.4.17-win64-VC14.zip (last December) from

extracted it to directly under C

then using the CLI went to its bin folder and ran

>httpd.exe -k install

to install it as a service

There was an issue with Windows 10 taking the port for WWW publishing service when I upgraded from Windows 7 that I had to stop so Apache would work.

1 Like

Yes, I had the same problem with XAMPP when I upgraded to Win 10. I got the impression www publishing service is IIS.

Should anyone be interested, I found a solution. I display a background image from the localhost and vm areas which if the server is not running don’t display. Crude perhaps but effective.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.