Skip to content
Advertisement

PHP cURL Received HTTP code 407 from proxy after CONNECT

I have a php curl with proxy problem.

Below is my code:

JavaScript

The format of proxies in proxy.txt is ip:port:user:pass and all proxies are working.

The problem is when I used $proxyipport and $proxyuserpwd in CURLOPT_PROXY and CURLOPT_USERPWD, the curl result threw the error Received HTTP code 407 from proxy after CONNECT. However, when I replaced those variables with actual ip:port, user:pass, it worked as normal. I also did an echo of $proxyipport and $proxyuserpwd and it showed me the exact ip:port and user:pass as expected.

Can someone please tell what I did wrong and how to fix that? Thanks in advance!

Advertisement

Answer

Most likely it is the newline n, so try:

JavaScript

If it is another hidden character(s) or a Windows format file then with r you can try:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement