Php-amqplib: PHP windows stream_socket_client(): unable to connect to tcp://localhost:5672

Created on 7 Apr 2017  路  5Comments  路  Source: php-amqplib/php-amqplib

Any time I try to run example code (https://github.com/rabbitmq/rabbitmq-tutorials/blob/master/php/receive.php)
I've got error:

`C:\php\php.exe C:_projects\instagram-service\send.php

PHP Fatal error: Uncaught ErrorException: stream_socket_client(): unable to connect to tcp://localhost:5672 (No connection could be made because the target machine actively refused it.
Fatal error: Uncaught ErrorException: stream_socket_client(): unable to connect to tcp://localhost:5672 (No connection could be made because the target machine actively refused it.
) in C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php:134
) in C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php:134
Stack trace:
Stack trace:

0 [internal function]: PhpAmqpLib\Wire\IO\StreamIO->error_handler(2, 'stream_socket_c...', 'C:\_projects\in...', 134, Array)

0 [internal function]: PhpAmqpLib\Wire\IO\StreamIO->error_handler(2, 'stream_socket_c...', 'C:\_projects\in...', 134, Array)

1 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php(134): stream_socket_client('tcp://localhost...', 10061, 'No connection c...', 3, 4, Resource id #13)

1 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php(134): stream_socket_client('tcp://localhost...', 10061, 'No connection c...', 3, 4, Resource id #13)

2 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AbstractConnection.php(196): PhpAmqpLib\Wire\IO\StreamIO->connect()

2 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AbstractConnection.php(196): PhpAmqpLib\Wire\IO\StreamIO->connect()

3 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AbstractConnection.php(180): PhpAmqpLib\Connection\AbstractConnection->connect()

3 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AbstractConnection.php(180): PhpAmqpLib\Connection\AbstractConnection->connect()

4 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AMQ in C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php on line 134

4 C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Connection\AMQ in C:_projects\instagram-service\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php on line 134

Process finished with exit code 255`

This happens with any port.
Firewall is turned OFF (I can run Node.js server on this or any another empty port).

question

Most helpful comment

I had the same problem: the broker was not running. I solved it by starting the broker:
rabbitmq-server -detached
Source: https://www.rabbitmq.com/man/rabbitmq-server.1.man.html

All 5 comments

This kind of errors occur when RabbitMQ is not running at all on the localhost.
Can you check that RabbitMQ server is running on this machine?
On Windows it should be shown as erl.exe in process list. You can also check result of rabbitmqctl status. The rabbitmqctl script should be in the RabbitMQ install directory under sbin directory.

when checking the status of rabbitmq getting this "
unable to connect to node 'rabbit@s132-148-22-119'"

@jasdeep343 which is another hint at the fact that the node may not be running on localhost (you haven't posted the entire output, so we can't confirm this hypothesis).

I had the same problem: the broker was not running. I solved it by starting the broker:
rabbitmq-server -detached
Source: https://www.rabbitmq.com/man/rabbitmq-server.1.man.html

@realwahl this solved my problem. thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

azngeek picture azngeek  路  7Comments

AndreKlang picture AndreKlang  路  7Comments

MaxwellZY picture MaxwellZY  路  5Comments

ramunasd picture ramunasd  路  4Comments

Majkl578 picture Majkl578  路  8Comments