Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

felloz's avatar

phpnative: cURL error

Hi, in my AppServiceProvider:

public function boot(): void
    {
        //MenuBar::create();

        Menu::new()
            ->appMenu()
            ->submenu(
                'About',
                Menu::new()
                    ->link('https://nativephp.com', 'NativePHP')
            )
            ->submenu(
                'View',
                Menu::new()
                    ->toggleFullscreen()
                    ->separator()
                    ->toggleDevTools()
            )
            ->register();

        Window::open()
            ->width(800)
            ->height(800);
    }

When i run php artisan native:serve i got this error:

PS E:\code\php\native\demo> php artisan native:serve

   Illuminate\Http\Client\ConnectionException

  cURL error 7: Failed to connect to localhost port 4000 after 2257 ms: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:4000/api/menu

  at vendor\laravel\framework\src\Illuminate\Http\Client\PendingRequest.php:924
    920▕                 });
    921▕             } catch (ConnectException $e) {
    922▕                 $this->dispatchConnectionFailedEvent();
    923▕
  ➜ 924▕                 throw new ConnectionException($e->getMessage(), 0, $e);
    925▕             }
    926▕         }, $this->retryDelay ?? 100, function ($exception) use (&$shouldRetry) {
    927▕             $result = $shouldRetry ?? ($this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $exception, $this) : true);
    928▕

  1   [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))

  2   vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:210
      GuzzleHttp\Exception\ConnectException::("cURL error 7: Failed to connect to localhost port 4000 after 2257 ms: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:4000/api/menu")
0 likes
4 replies
felloz's avatar

Im getting same error for Linux, it's for MAC's only?

finchy70's avatar

I am having this same issue trying to serve a desktop app on Windows 11.

1 like

Please or to participate in this conversation.