doubiao9775 2016-03-14 01:35
浏览 4292
已采纳

curl(7):无法连接到localhost端口8000:连接被拒绝

Hello I am testing the endpoint and when I run php testing.php I get this error. Any help would be appreciated it.

Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 7: Failed to connect to localhost port 8000: Connection refused [url] http://localhost:8000/api/programmers' guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php:359 ...

I've tried 127.0.0.1 as well and it didnt work

here is testing.php

<?php

require __DIR__.'/vendor/autoload.php';

use Guzzle\Http\Client;

// create our http client (Guzzle)
$client = new Client('http://localhost:8000', array(
    'request.options' => array(
        'exceptions' => false,
    )
));

$nickname = 'ObjectOrienter'.rand(0, 999);
$data = array(
    'nickname' => $nickname,
    'avatarNumber' => 5,
    'tagLine' => 'a test dev!'
);

$request = $client->post('/api/programmers', null, json_encode($data));
$response = $request->send();

echo $response;
echo "

";
  • 写回答

4条回答 默认 最新

  • dongruo0909 2016-03-14 01:45
    关注

    if you are using linux, make sure the server is running using

    /etc/init.d/httpd status
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测