4

I am using the latest version of guzzle.

(from composer.json)
"guzzlehttp/guzzle": "~5" 

(from composer.lock)
"name": "guzzlehttp/guzzle",
"version": "5.2.0",

When I attempt to request (GET or POST) with a URL that contains a PORT number:

$response = $client->get('http://www.hostdnshere.com:8888', array());

I get the following error:

string(68) "cURL error 7: Failed to connect to 000.000.000.000: Permission denied"

When I do the same but omit the PORT:

$response = $client->get('http://www.hostdnshere.com', array());

The request succeeds without issue. I have searched the documentation and Googled the web but cannot find out how to set the port for the host since it cannot be included.

Additionally, I have tested it all using cURL on the server form which the requests are being sent, with and without the PORT, works like a charm no matter what so I know its not an issue with the Server, DNS, Proxies, or PORTS.

5
  • Saw your issue on GitHub, unfortunately I can't reproduce what you're describing Commented Mar 12, 2015 at 18:48
  • Give concrete hostname, this seems to not be guzzle issue but invalid port specified, or auth protected area Commented Mar 12, 2015 at 18:50
  • Yeah, I reproduced your test and it works fine. I am running Guzzle from a PHP class within a Laravel 4.2 application where I am getting the error. When I check the composer.json file Guzzle is only listed in there once as displayed above, but when I look in the composer.lock file I see guzzle/guzzle as well as guzzlehttp/guzzle as being installed by composer, even when I delete the vendor bin and lock file and do a clean composer install. So some other package is relying on Guzzle but since the two have separate namespaces I would assume they would not conflict with one another. Commented Mar 12, 2015 at 19:07
  • And I am fully qualifying the latest version in the PHP class use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; Commented Mar 12, 2015 at 19:11
  • As well as fully qualifying it on creation to make sure the latest Guzzle is being used to instantiate the object. $client = new GuzzleHttp\Client(); Commented Mar 12, 2015 at 19:15

1 Answer 1

3

For all those banging their heads against the wall due to the

"cURL error 7: Failed to connect to 000.000.000.000: Permission denied"

error, it all boils down to 'SELINUX'. That is right, any cURL wrapper written in any programming language can be affected by the fact that when 'SELINUX' is set to 'enforcing' it takes issue with cURL being executed against a URL that has a non-standard PORT in it (i.e. my.domain.com:8888).

Recommended for local development only, if you wish to use non-standard PORTS in your URL's, is to set 'SELINUX' to 'disabled'. The proper solution in production will be to use clean URLs without PORTs in them in order to leave 'SELINUX' enabled.

Open:

nano /etc/selinux/config

Locate:

SELINUX=enforcing

Change:

SELINUX=disabled

Those using CentOS will most likely be running into this issue since 'SELINUX' is set to 'enforcing' by default.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Remember to reboot after making the change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.