Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 404 Site not found: herd.sock not found #228

Closed
ogamacheDev opened this issue Oct 27, 2023 · 10 comments
Closed

[Bug]: 404 Site not found: herd.sock not found #228

ogamacheDev opened this issue Oct 27, 2023 · 10 comments

Comments

@ogamacheDev
Copy link

ogamacheDev commented Oct 27, 2023

Operating system version

macOS Ventura 13.6

System architecture

Intel (x86)

Herd Version

1.3.1

PHP Version

No response

Bug description

After a fresh install of Herd, I am unable to access the newly installed projects, I get a 404 site not found. After some investigation, I found in the nginx log file this:

2023/10/27 08:32:23 [crit] 16363#134482: *1 connect() to unix:/Users/ogamache/Library/Application Support/Herd/herd.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/ogamache/Library/Application Support/Herd/herd.sock:", host: "radical-test.test"

Steps to reproduce

  1. Install Herd
  2. Park a folder
  3. Install a new project
  4. Check if it works
  5. Check the logs

Relevant log output

2023/10/27 08:32:23 [crit] 16363#134482: *1 connect() to unix:/Users/ogamache/Library/Application Support/Herd/herd.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/ogamache/Library/Application Support/Herd/herd.sock:", host: "radical-test.test"
@mpociot
Copy link
Member

mpociot commented Oct 27, 2023

What's the status of your Herd services?

@ogamacheDev
Copy link
Author

Everything seems to be up and running:
image

@mpociot
Copy link
Member

mpociot commented Oct 27, 2023

Could you please try and install another PHP version (like 8.1) and switch between those versions. Does that fix the problem for you?

Could you also show me the contents of your ~/Library/Application Support/Herd directory?

@ogamacheDev
Copy link
Author

I just tried changing php versions and it didn't change anything, still can't access the site. However, the logging stopped. But the herd.sock file still seems to be missing.
image

@mpociot
Copy link
Member

mpociot commented Oct 27, 2023

Looks like it's there 😅
It's a symlink that points to the correct socket site based on your PHP version.

Which error do you get exactly? The 404 from Herd?
If so, could you share your sites listing/UI or the list of parked paths?

@ogamacheDev
Copy link
Author

The symlink is there but It can't find it (sorry for the french screenshot)
image

I get a 404 site not found error, I parked my folder correctly and the site is found in the site list:
image

Capture d’écran, le 2023-10-27 à 09 07 17

@mpociot
Copy link
Member

mpociot commented Oct 27, 2023

If you don't mind, do you have a minute to debug this with me via screensharing (like Tuple/Google Meet)?

@ogamacheDev
Copy link
Author

ogamacheDev commented Oct 27, 2023

Of course. Should you send me the link on my email?

@mpociot
Copy link
Member

mpociot commented Oct 27, 2023

https://meet.google.com/uwf-odwj-poj

Here you go :)

@ogamacheDev
Copy link
Author

ogamacheDev commented Oct 27, 2023

For some people that might get this issue:

The issue was that Herd didn't recognize my project structure, so no driver was loaded. In that case, you can create you own driver inside the project in a file called LocalValetDriver.php:

<?php

use Valet\Drivers\BasicValetDriver;

class LocalValetDriver extends BasicValetDriver
{
    /**
     * Determine if the driver serves the request.
     */
    public function serves(string $sitePath, string $siteName, string $uri): bool
    {
        return true;
    }

    /**
     * !!!! ENTER THE WEB ROOT IN THE $staticFilePath VARIABLE
     * Determine if the incoming request is for a static file.
     */
    public function isStaticFile(string $sitePath, string $siteName, string $uri)
    {
        $staticFilePath = $sitePath.'/public'.$uri;

        if ($this->isActualFile($staticFilePath)) {
            return $staticFilePath;
        }

        return false;
    }

    /**
     * !!!! ENTER THE WEB ROOT IN THE $sitePath VARIABLE
     * Get the fully resolved path to the application's front controller.
     */
    public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string
    {
        return parent::frontControllerPath(
            $sitePath.'/public',
            $siteName,
            $this->forceTrailingSlash($uri)
        );
    }

    /**
     * Redirect to uri with trailing slash.
     */
    private function forceTrailingSlash($uri)
    {
        if (substr($uri, -1 * strlen('/wp/wp-admin')) == '/wp/wp-admin') {
            header('Location: '.$uri.'/');
            exit;
        }

        return $uri;
    }
}

Hope it helps. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants