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

SandunLK's avatar

cURL error 7: Failed to connect to 188.166.107.87 port 8000: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Hey I create a Laravel 5.4 Application with GuzzleHttp. When I host it in the PHP server and Try to post request to another API hosted in DigitalOcean(NodeJS App) it gives the above error. But It works in the Localhost well. My Guzzle Request is here.

$client = new Client([
                    'base_uri' => '',
                    'timeout' => 0,
                    'connect_timeout' => 0,
                    'headers' => [
                        'Content-Type' => 'application/json',
                    ],]);

                $response = $client->request('POST', $target, [
                    'json' => [
                        'HotelID' => $user,
                        'authcode' => $authcode,
                        'userData' => [
                            'NIC' => $NIC,
                            'Name' => $name
                        ],
                        'reservation' => [
                            'checkin_date' => $checkin_date,
                            'checkout_data' => $checkout_data,
                            'payment' => $payment
                        ],
                        'rooms' => [
                            'TypeA' => $TypeA_rooms,
                            'TypeB' => $TypeB_rooms,
                            'TypeC' => $TypeC_rooms,
                            'TypeD' => $TypeD_rooms,
                            'TypeE' => $TypeE_rooms,
                            'TypeF' => $TypeF_rooms
                        ]
                    ]]);

How I fix this issue. Help me.

0 likes
2 replies
arukomp's avatar

are you sure your API is running on port 8000 on Digital Ocean?

3 possible causes:

  1. The API is not running
  2. The API is running on a different port on Digital Ocean
  3. The port 8000 is blocked on DO's firewall. You need to add the port to the whitelist. The steps for that differ depending on which OS you are running on your Digital Ocean droplet.
SandunLK's avatar

But when I called other API using this It gives the same error.

Please or to participate in this conversation.