herd-community icon indicating copy to clipboard operation
herd-community copied to clipboard

[Bug]: failed to start herd helper service

Open rahulsync opened this issue 1 year ago • 13 comments

Platform

Windows

Operating system version

Windows 11 Pro

System architecture

Intel (x86)

Herd Version

1.0.1

PHP Version

No response

Bug description

I'm getting the said error while installing the setup file. Please Note I Have x64 Processor (i7 14700K)

Steps to reproduce

No response

Relevant log output

No response

rahulsync avatar Mar 29 '24 14:03 rahulsync

i have the same issue, the herd helper service dont start and i tried everything i can...

lvltech-mx avatar Apr 01 '24 18:04 lvltech-mx

However, You could install the software and you can create your website too, all the dependencies would be downloaded without any problem, but since herd port is offline due to failure of herd port helper service, you would not be able to run "laravel.test" local website, but there is one ugly solution to this, maybe temporary, you could go to the project directory and you can use good old "php artisan serve" command and you'll see your website on localhost. Cheers!

rahulsync avatar Apr 01 '24 18:04 rahulsync

Same issue Installed 1.0.1 today. Created a new site and opened in browser and nothing. nginx serving ok at 127.0.0.1 and responding with 404 Not anything in windows logs on this. Looks like nvm.exe also fails <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> [-](https://github.com/beyondcode/herd-community/issues/566#) <System> <Provider Name="PowerShell" /> <EventID Qualifiers="0">403</EventID> <Version>0</Version> <Level>4</Level> <Task>4</Task> <Opcode>0</Opcode> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2024-04-01T21:37:47.8907863Z" /> <EventRecordID>4353</EventRecordID> <Correlation /> <Execution ProcessID="39628" ThreadID="0" /> <Channel>Windows PowerShell</Channel> <Computer>play</Computer> <Security /> </System> [-](https://github.com/beyondcode/herd-community/issues/566#) <EventData> <Data>Stopped</Data> <Data>Available</Data> <Data>NewEngineState=Stopped PreviousEngineState=Available SequenceNumber=15 HostName=ConsoleHost HostVersion=5.1.22621.2506 HostId=d3bb07b2-acac-4eab-9622-4ab756d098ba HostApplication=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command Restart-Service -Name HerdHelper EngineVersion=5.1.22621.2506 RunspaceId=300001a0-c1b1-4a27-84a5-0f70353f08c7 PipelineId= CommandName= CommandType= ScriptName= CommandPath= CommandLine=</Data> </EventData> </Event>

EDIT: Found some in the System log viewer Information: Create URL group 0xFC00000820000001. Status 0x0. Process Id 0xD390 Executable path \Device\HarddiskVolume3\Users\46730\.config\herd\bin\HerdHelper.exe, User SYSTEM

Error: Unable to bind to the underlying transport for [::]:5000. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine. The data field contains the error number.

kimett avatar Apr 01 '24 21:04 kimett

What happens if you run sc.exe query HerdHelperfrom your terminal?

If it detects the service but the state is not "RUNNING", can you try running it via a powershell with admin priviledges:

sc.exe start HerdHelper

Is there an error? You can also open Herd, go to the General settings and set it to a different port? It sounds like port 5000 is already in use.

sschlein avatar Apr 03 '24 14:04 sschlein

i have the same issue. after restart service is running good, but doesn't last long failed again

suterlan avatar Apr 03 '24 16:04 suterlan

Found the issue. Port 5000 is occupied by vmms.exe. I tried a different port my first run and hit another used one.

to check use netstat -ab to see used ports in win 11. Should be possible to get an non-used port from the OS programmatically instead of the user trying to debug what happens as an improvement

After selecting a unused port HerdHelper is now green in the settings pane but still can't use the FQDN to open the web app. Don't know where to look for logs from HerdHelper if it has issues with or even trying to update the host definitions

UPDATE: Instead tried to create a new site and then it works. So pre-existing sites aren't verified to be existing when HerdHelper successfully starts from what I can see

kimett avatar Apr 03 '24 16:04 kimett

When I try to start the service in services.msc I get an:

Windows could not start the Herd Helper service on Local Computer. Error 193: 0xc1.

When I look in the Event Viewer it says:

The Herd Helper service failed to start due to the following error: Herd Helper is not a valid Win32 application.

GeorgThomassen avatar Apr 05 '24 11:04 GeorgThomassen

@GeorgThomassen That sounds super odd, which Windows version do you run? It might need a new install as the exe could be broken

@kimett This might be an improvement for a future update that we'll take into account. The helper itself only writes to your hosts file, so in theory you can ann all sites there manually:

127.0.0.1 your-site.test
127.0.0.1 your-other-site.test
etc

The HerdHelper also writes all directorsy from your parked paths as well as all linked sites to the hosts file, so once you get it up and running, everything should be there after a restart of herd or after changing a directory name in a parked path.

sschlein avatar Apr 05 '24 12:04 sschlein

Same problem, the service starts and stops at the same moment, with no error: Screenshot 2024-04-21 210428 Screenshot 2024-04-21 210450

Manually adding entries to the hosts file helped.

andriizaiets avatar Apr 21 '24 18:04 andriizaiets

@sschlein i tried ur suggestion here's what i got : image

and when i try to change the port with administrator prievlieges it logs an error when changing it.

inventor7 avatar May 05 '24 11:05 inventor7

Ive installed herd today and I got the same issue

devfastated avatar May 16 '24 22:05 devfastated

@GeorgThomassen That sounds super odd, which Windows version do you run? It might need a new install as the exe could be broken

@kimett This might be an improvement for a future update that we'll take into account. The helper itself only writes to your hosts file, so in theory you can ann all sites there manually:

127.0.0.1 your-site.test
127.0.0.1 your-other-site.test
etc

The HerdHelper also writes all directorsy from your parked paths as well as all linked sites to the hosts file, so once you get it up and running, everything should be there after a restart of herd or after changing a directory name in a parked path.

I installed Herd today and had the same issue where a new Laravel app could not connect when starting up in the browser. The HerdHelper service status indicator indicates red - as in the screenshot - so I asssumed it wasn't running - but checking the services under Task Manager indicated it was.

Eventually I had to manually edit the hosts file with the domain app-name.test to bind to 127.0.0.1 per your comment and it worked in the browser. Have no idea what's causing the issue.

The status indicator still shows red, even after modifying the hosts file manually. It's quite a frustrating to issue to have as I was going around in circles trying to figure out what was the issue.

BTW, the OS is Windows 10.

image

amhassen97 avatar May 18 '24 14:05 amhassen97

If the Helper is running but the indicator is red, that means that the Herd app can't connect to the exposed web service of the helper.

I've a hard time debugging this as we've never been able to reproduce or pin down the issue on our machines.

In my opinion the most likely reason is a firewall or anti virus issue and we need to find a way to solve this.

Once the helper is running and the app is able to connect, you could create a new folder in a parked directly or link a project to trigger the write to the hosts file.

sschlein avatar May 18 '24 14:05 sschlein

im using w10, Ive got no antivirus and im using the default windows firewall, if i disable it, it doesnt work either, the indicator is red and PS C:\WINDOWS\system32> sc.exe query HerdHelper

NOMBRE_SERVICIO: HerdHelper TIPO : 10 WIN32_OWN_PROCESS ESTADO : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) CÓD_SALIDA_WIN32 : 0 (0x0) CÓD_SALIDA_SERVICIO: 0 (0x0) PUNTO_COMPROB. : 0x0 INDICACIÓN_INICIO : 0x0

geomorillo avatar May 24 '24 23:05 geomorillo

Yeah pretty much the same for me, it was on my personal machine

amhassen97 avatar May 25 '24 09:05 amhassen97

Apparently, the firewall was the cause, after it was stopped everything started working normally ✅

amralsaleeh avatar May 25 '24 10:05 amralsaleeh

Apparently, the firewall was the cause, after it was stopped everything started working normally ✅

Which one do you use?

sschlein avatar May 25 '24 14:05 sschlein

Hey folks, can you please try this NEW debug version?

This one should heal itself it the port is already in use, fix not existing hosts files, write to read-only hosts files and only use IPv6 in cases that this is properly configured on the host machine.

Download

  • Install debug version
  • Restart Herd
  • Also check the logs at %USERPROFILE%\AppData\Roaming\Herd\logs

You can either post the logs here or send them to [email protected]

Thanks for helping us with debugging.

sschlein avatar Jun 03 '24 09:06 sschlein

main.log

Hope this helps with debugging the issue.

kmaphane avatar Jun 08 '24 17:06 kmaphane

Could you also share the herdhelper log file? Thanks!

sschlein avatar Jun 08 '24 17:06 sschlein

Could you also share the herdhelper log file? Thanks!

The log I sent above is from this file path: %USERPROFILE%\AppData\Roaming\Herd\logs

I have nothing in this file path from Herd: C:\Windows\System32\logs. I have enabled it though

image

the only log I have from this file path had to do nginx which I resolved: %USERPROFILE%.config\herd\Log

kmaphane avatar Jun 08 '24 17:06 kmaphane

I am facing the same issue, here is something that I have got in logs:

2024-06-10 21:56:19.976 +05:30 [INF] IPv6 is supported. Added http://[::1]:5000/ to listener prefixes. 2024-06-10 21:56:19.990 +05:30 [ERR] An error occurred while starting the HTTP server: The network location cannot be reached. For information about network troubleshooting, see Windows Help. 2024-06-10 21:56:19.991 +05:30 [ERR] An error occurred: Cannot access a disposed object. Object name: 'System.Net.HttpListener'. 2024-06-10 21:56:19.993 +05:30 [ERR] BackgroundService failed System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.HttpListener'. at System.Net.HttpListener.Stop() at HerdHelper.Worker.ExecuteAsync(CancellationToken stoppingToken) at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService) 2024-06-10 21:56:20.027 +05:30 [FTL] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted. System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.HttpListener'. at System.Net.HttpListener.Stop() at HerdHelper.Worker.ExecuteAsync(CancellationToken stoppingToken) at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService) 2024-06-10 21:56:20.028 +05:30 [INF] Application is shutting down... 2024-06-10 21:56:20.029 +05:30 [DBG] Hosting stopping 2024-06-10 21:56:20.037 +05:30 [DBG] Hosting stopped

bytesandcode avatar Jun 11 '24 07:06 bytesandcode

Windows does not have dnsmasq, can this be causing issues?

bytesandcode avatar Jun 11 '24 08:06 bytesandcode

No, this is why we have this service that writes to your hosts file instead of using dnsmasq 🙂

Did you try other ports? It seems that something is blocking the service from starting up and opening the port so that the Herd app an access the helper service. Any firewall or anti virus software that could cause this?

sschlein avatar Jun 11 '24 09:06 sschlein

I have tried using different ports and disabling the firewall, but nothing works. It appears that the service responsible for writing domains to the hosts file is not functioning correctly. I manually added the IP address (127.0.0.1) and the domain (example.test) to the hosts file. Wildcards (*.test) are not supported too in the hosts file. So, the only option is to write all the domains manually.

bytesandcode avatar Jun 12 '24 07:06 bytesandcode

@bytesandcode

would you please try this Helper? Download

You can do that by replacing the HerdHelper.exe from %USERPROFILE%.config\herd\bin with the one from the download. You might need to stop the service first before you can do that, use the commands below.

Please open a powershell with admin permissions to stop and start the helper:

sc.exe stop HerdHelper
//replace the exe file
sc.exe start HerdHelper

After that, the HerdHelper should either turn green in Herd or at least give us a new herdhelper logfile with more information. The logs are at C:\Windows\System32\logs again.

sschlein avatar Jun 12 '24 09:06 sschlein

herdhelper20240612.txt Here is the log file. The status is still red. Here is output from PowerShell: PS C:\Windows\system32> sc.exe stop HerdHelper

SERVICE_NAME: HerdHelper TYPE : 10 WIN32_OWN_PROCESS STATE : 3 STOP_PENDING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 PS C:\Windows\system32> sc.exe start HerdHelper

SERVICE_NAME: HerdHelper TYPE : 10 WIN32_OWN_PROCESS STATE : 2 START_PENDING (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x7d0 PID : 15484 FLAGS : PS C:\Windows\system32>

bytesandcode avatar Jun 12 '24 10:06 bytesandcode

What happens if you open 127.0.0.1:5000/status or localhost:5000/status?

sschlein avatar Jun 12 '24 11:06 sschlein

503, Service Unavailable! But http://127.0.0.1/example.test works.

bytesandcode avatar Jun 13 '24 05:06 bytesandcode

@bytesandcode

Could you do me a favor?

sc.exe squery HerdHelper

This should display this:

SERVICE_NAME: HerdHelper
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

You can also verify this with your windows services (sorry German screenshot): CleanShot 2024-06-13 at 09 11 05

The logs of the helper at C:\Windows\System32\logs should be like this:

2024-06-13 09:08:15.523 +02:00 [INF] Request to /status endpoint.
2024-06-13 09:08:33.229 +02:00 [INF] Application is shutting down...
2024-06-13 09:08:33.233 +02:00 [DBG] Hosting stopping
2024-06-13 09:08:33.261 +02:00 [INF] HTTP Server stopped.
2024-06-13 09:08:33.273 +02:00 [DBG] Hosting stopped
2024-06-13 09:09:22.049 +02:00 [DBG] Hosting starting
2024-06-13 09:09:22.154 +02:00 [INF] Config path: C:\ProgramData\Herd\service.json.
2024-06-13 09:09:22.158 +02:00 [INF] Config file with port exists, using port: 5000.
2024-06-13 09:09:22.166 +02:00 [INF] Application started. Hosting environment: Production; Content root path: C:\Users\seb\.config\herd\bin\
2024-06-13 09:09:22.169 +02:00 [DBG] Hosting started
2024-06-13 09:09:22.193 +02:00 [INF] HTTP Server started on http://localhost:5000/.
2024-06-13 09:09:24.738 +02:00 [INF] Request to /status endpoint.

If you go to 127.0.0.1:5000/status, a new line with the request to the status endpoint should be available.

I checked the code 10 times again, and the helper does not return 503 for any request, so I am not even sure that you are hitting the helper and not some other service on your machine...

sschlein avatar Jun 13 '24 07:06 sschlein