- Saved searches
- Use saved searches to filter your results more quickly
- curl: (56) Recv failure: Connection reset by peer #4
- curl: (56) Recv failure: Connection reset by peer #4
- Comments
- Install php7.3 extension
- Add default timezone
- Install composer globally
- Copy our config files for php7.3 fpm and php7.3 cli
- Reconfigure system time
- Laravel writing rights
- Create Laravel folders (mandatory)
- Change folder permission
- cURL error 77 with PHP-FPM after yum update
- Hitting the Payment Gateway’s endpoint using the curl Executable
- Invoking cURL through PHP-FPM
- What Had Changed Recently?
- The Fix
- The Return Of The Issue
- The True Root Cause
- Vesta Control Panel — Forum
- Nginx + PHP7.0-FPM — Curl Not working with Proxy
- php5.6-fpm curl stops working (Couldn’t resolve host)
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curl: (56) Recv failure: Connection reset by peer #4
curl: (56) Recv failure: Connection reset by peer #4
Comments
i try to use php7.3 fpm to my laravel and add all neccessary file for laravel..
but when i run the docker and check if i can access the 0.0.0.0:9000 / 127.0.0.1:900 it shows that i always get this response curl: (56) Recv failure: Connection reset by peer
MAINTAINER Ran Andrew Abad
LABEL Vendor=»dmiseev»
LABEL Description=»PHP-FPM v7.3″
LABEL Version=»1.0.0″
ENV LYBERTEAM_TIME_ZONE America/New_York
#RUN apt-get install -y python-software-properties
RUN apt-get update -yqq
&& apt-get install -yqq
ca-certificates
git
gcc
make
wget
mc
curl
supervisor
sendmail
RUN DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-software-properties
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
RUN DEBIAN_FRONTEND=noninteractive LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
Install php7.3 extension
RUN apt-get update -yqq
&& apt-get install -yqq
php7.3-pgsql
php7.3-mysql
php7.3-opcache
php7.3-common
php7.3-mbstring
php7.3-soap
php7.3-cli
php7.3-intl
php7.3-json
php7.3-xsl
php7.3-imap
php7.3-ldap
php7.3-curl
php7.3-gd
php7.3-dev
php7.3-fpm
php7.3-bcmath
php7.3-imagick
php7.3-zip
php7.3-zmq
php7.3-apcu
&& apt-get install pkg-config
&& pecl install mongodb
&& echo «extension=mongodb.so» > /etc/php/7.3/cli/conf.d/ext-mongodb.ini
&& echo «extension=mongodb.so» > /etc/php/7.3/fpm/conf.d/ext-mongodb.ini
&& apt-get install -y -q —no-install-recommends
ssmtp
Add default timezone
RUN echo $LYBERTEAM_TIME_ZONE > /etc/timezone
RUN echo «date.timezone=$LYBERTEAM_TIME_ZONE» > /etc/php/7.3/cli/conf.d/timezone.ini
Install composer globally
RUN echo «Install composer globally»
RUN curl -sS https://getcomposer.org/installer | php — —install-dir=/usr/bin/ —filename=composer
Copy our config files for php7.3 fpm and php7.3 cli
COPY php-conf/php.ini /etc/php/7.3/cli/php.ini
COPY php-conf/php-fpm.ini /etc/php/7.3/fpm/php.ini
COPY php-conf/php-fpm.conf /etc/php/7.3/fpm/php-fpm.conf
COPY php-conf/www.conf /etc/php/7.3/fpm/pool.d/www.conf
RUN usermod -aG www-data www-data
Reconfigure system time
RUN dpkg-reconfigure -f noninteractive tzdata
RUN mkdir -p /var/www/sendah-shop
ADD ./ /var/www/sendah-shop
Laravel writing rights
RUN chgrp -R www-data /var/www/sendah-shop/storage /var/www/sendah-shop/bootstrap/cache
RUN chmod -R ug+rwx /var/www/sendah-shop/storage /var/www/sendah-shop/bootstrap/cache
Create Laravel folders (mandatory)
RUN mkdir -p /var/www/sendah-shop/storage/framework
RUN mkdir -p /var/www/sendah-shop/storage/framework/sessions
RUN mkdir -p /var/www/sendah-shop/storage/framework/views
RUN mkdir -p /var/www/sendah-shop/storage/meta
RUN mkdir -p /var/www/sendah-shop/storage/cache
RUN mkdir -p /var/www/sendah-shop/storage/users
RUN mkdir -p /var/www/sendah-shop/storage/users/img
RUN mkdir -p /var/www/sendah-shop/public/uploads/
RUN mkdir -p /secrets/cloudstorage/
RUN mkdir -p /var/www/sendah-shop/public/env/
RUN ln -s /var/www/sendah-shop/public/env/* /var/www/sendah-shop/
RUN ln -s /var/www/sendah-shop/storage/users/img/
Change folder permission
RUN chmod -R 0777 /var/www/sendah-shop/storage/
RUN chmod -R 0777 /var/www/sendah-shop/public/uploads/
RUN chmod -R 0777 /var/www/sendah-shop/bootstrap/cache
COPY start.sh /start.sh
RUN chmod +x /start.sh
hope you can help me thanks
The text was updated successfully, but these errors were encountered:
cURL error 77 with PHP-FPM after yum update
Recently a client reported that checkout was broken on their ecommerce website.
After some quick investigation, I found that the application code responsible for speaking with the payment gateway was logging the following error:
Here, I’ll outline my approach to solving this problem.
Hitting the Payment Gateway’s endpoint using the curl Executable
The site was using was Authorize.NET as its payment gateway. The code was specifically hitting an endpoint at https://api2.authorize.net . I tried hitting the endpoint myself using the curl executable while SSH-ed into one of their web servers to see if the issue would reproduce…
$ curl https://api2.authorize.net/xml/v1/request.api <"messages":<"resultCode":"Error","message":[<"code":"E00003","text":"Root element is missing.">]>>
No cURL error 77…the problem did not seem to reproduce…
Invoking cURL through PHP-FPM
The application code, of course, wasn’t running curl via command line invocation of the curl executable. Instead, a PHP-FPM process was executing a script that was using PHP cURL functions.
As such as decided to test that way. I quickly created a testing script…
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api2.authorize.net"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); var_dump($output) . PHP_EOL; var_dump(curl_error($ch)) . PHP_EOL; var_dump(curl_errno($ch)) . PHP_EOL;
I put it in the webroot of the server I was SSH-ed into and ran it via a PHP-FPM process as follows:
$ curl --resolve www.example.com:80:127.0.0.1 http://www.example.com/mpc-curl-auth-net-test.php bool(false) string(0) "" int(77)
What Had Changed Recently?
This reminded me of an issue I had seen not long ago where DNS lookups failed only when running curl via a script executed by PHP-FPM. In that case I had tracked it back to a yum update.
As such, I decided to check /var/log/yum.log to see if any packages had been update recently….
Oct 24 03:53:38 Updated: nspr.x86_64 4.19.0-1.43.amzn1 Oct 24 03:53:39 Updated: nss-util.x86_64 3.36.0-1.54.amzn1 Oct 24 03:53:39 Updated: nss-softokn-freebl.x86_64 3.36.0-5.42.amzn1 Oct 24 03:53:39 Updated: nss-softokn.x86_64 3.36.0-5.42.amzn1 Oct 24 03:53:39 Updated: nss-sysinit.x86_64 3.36.0-5.82.amzn1 Oct 24 03:53:39 Updated: nss.x86_64 3.36.0-5.82.amzn1 Oct 24 03:53:39 Updated: nss-tools.x86_64 3.36.0-5.82.amzn1 Oct 24 03:53:39 Updated: python26-paramiko.noarch 1.15.1-2.7.amzn1 Oct 24 03:53:39 Updated: python27-paramiko.noarch 1.15.1-2.7.amzn1
Bingo again! A yum update had run the night before…
The Fix
Going off my experience with the DNS issue, I guessed that restarting php-fpm might fix the issue. As such, I decided to give it a try…
$ sudo service php-fpm restart
Then, I re-ran my testing script
$ curl --resolve www.example.com:80:127.0.0.1 http://www.example.com/mpc-curl-auth-net-test.php string(1233) " . " string(0) "" int(0)
The Return Of The Issue
This project was running a fleet of AWS EC2 instances and we manually restarted php-fpm across all. However, later that same day the client reported the issue had reared its ugly head again. This time, however it was only occurring sporadicly.
Digging in, I found this was due a fresh EC2 instance being introducing into the auto scaling group.
- Instance comes online with old NSS packages
- PHP-FPM starts
- yum update runs
- Bad times
In order to fix this we baked a new AMI with the NSS packages already updated. Now, when a new EC2 instance came online this would happen…
- Instance comes online with new NSS packages
- PHP-FPM starts
The True Root Cause
While I would love to know exactly why updating those packages caused the error when running curl via PHP-FPM unfortunately I didn’t have the opportunity to truly get to the bottom of it. If you’ve run into this same issue and went deeper on it than I did I’d love to hear about it in the comments below…
Hi, I’m Max!
I’m a software developer who mainly works in PHP, but loves dabbling in other languages like Go and Ruby. Technical topics that interest me are monitoring, security and performance. I’m also a stickler for good documentation and clear technical writing.
During the day I lead a team of developers and solve challenging technical problems at Rightpoint where I mainly work with the Magento platform. I’ve also spoken at a number of events.
If you’d like to get in contact, you can find me on Twitter and LinkedIn.
The entire source of this site is available on Github.
If there’s a specific topic you’re looking to read about try searching or browsing by tag.
© 2023 Max Chadwick
Vesta Control Panel — Forum
Nginx + PHP7.0-FPM — Curl Not working with Proxy
theRiyazSaifi Posts: 3 Joined: Thu Sep 06, 2018 5:28 pm
Os: Ubuntu 15x Web: nginx + php-fpm
Nginx + PHP7.0-FPM — Curl Not working with Proxy
Post by theRiyazSaifi » Thu Sep 06, 2018 5:31 pm
I am using Vesta control panel( nginx + PHP7-FPM) this is ubuntu 16.4. I am getting blank response from curl when i use proxy on it otherwise its working fine.
function checkpoint($xxxx, $useragent, $url, $cookie = 0, $data = 0, $httpheader = array(), $proxy = 0) < $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_VERBOSE, false); if($proxy)< curl_setopt($ch, CURLOPT_PROXY, $proxy); >curl_setopt($ch, CURLOPT_HEADER, 1); $response = curl_exec($ch); $httpcode = curl_getinfo($ch); return array($httpcode, $response); > >
This return me a blank output.
# Server globals user www-data; worker_processes auto; worker_rlimit_nofile 65535; error_log /var/log/nginx/error.log crit; pid /var/run/nginx.pid; # Worker config events < worker_connections 1024; use epoll; multi_accept on; >http < # Main settings sendfile on; tcp_nopush on; tcp_nodelay on; client_header_timeout 1m; client_body_timeout 1m; client_header_buffer_size 2k; client_body_buffer_size 256k; client_max_body_size 256m; large_client_header_buffers 4 8k; send_timeout 300; keepalive_timeout 60 60; reset_timedout_connection on; server_tokens off; server_name_in_redirect off; server_names_hash_max_size 512; server_names_hash_bucket_size 512; fastcgi_buffering off; # Log format log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format bytes '$body_bytes_sent'; #access_log /var/log/nginx/access.log main; access_log off; # Mime settings include /etc/nginx/mime.types; default_type application/octet-stream; # Proxy settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_header Set-Cookie; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; # Compression gzip on; gzip_comp_level 9; gzip_min_length 512; gzip_buffers 8 64k; gzip_types text/plain text/css text/javascript text/js text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss application/x-font-ttf image/svg+xml font/opentype; gzip_proxied any; gzip_disable "MSIE 5\."; # Cloudflare https://www.cloudflare.com/ips set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 104.16.0.0/12; set_real_ip_from 108.162.192.0/18; set_real_ip_from 131.0.72.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 162.158.0.0/15; set_real_ip_from 172.64.0.0/13; set_real_ip_from 173.245.48.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 190.93.240.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; #set_real_ip_from 2400:cb00::/32; #set_real_ip_from 2606:4700::/32; #set_real_ip_from 2803:f800::/32; #set_real_ip_from 2405:b500::/32; #set_real_ip_from 2405:8100::/32; #set_real_ip_from 2c0f:f248::/32; #set_real_ip_from 2a06:98c0::/29; real_ip_header CF-Connecting-IP; # SSL PCI Compliance ssl_session_cache shared:SSL:10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; # Error pages error_page 403 /error/403.html; error_page 404 /error/404.html; error_page 502 503 504 /error/50x.html; # Cache settings proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m; proxy_cache_key "$host$request_uri $cookie_user"; proxy_temp_path /var/cache/nginx/temp; proxy_ignore_headers Expires Cache-Control; proxy_cache_use_stale error timeout invalid_header http_502; proxy_cache_valid any 1d; # Cache bypass map $http_cookie $no_cache < default 0; ~SESS 1; ~wordpress_logged_in 1; ># File cache settings open_file_cache max=10000 inactive=30s; open_file_cache_valid 60s; open_file_cache_min_uses 2; open_file_cache_errors off; # Wildcard include include /etc/nginx/conf.d/*.conf; >
php5.6-fpm curl stops working (Couldn’t resolve host)
All of a sudden our Ubuntu php5.6-fpm server has stopped working with curl requests. Here is what i have found: Works when ran from the console php test.php . Works via wet from console wget -qO- https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 | cat Works using curl from console ums-admin@svr1:/var/www/propertymonitor.ae/htdocs/v2$ curl https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 However calling the script via php-fpm on https://example.com/test.php it does not work and complains about DNS lookup failure?! Restarting php5.6-fpm and it starts working again?! Code below:
else < echo 'Response: ' . $data; >// close curl resource to free up system resources curl_close($ch); ?>
cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4 search example.com
64 bytes from 8.8.8.8: icmp_seq=3150 ttl=46 time=129 ms 64 bytes from 8.8.8.8: icmp_seq=3151 ttl=46 time=124 ms 64 bytes from 8.8.8.8: icmp_seq=3152 ttl=46 time=124 ms 64 bytes from 8.8.8.8: icmp_seq=3153 ttl=46 time=124 ms ^C --- 8.8.8.8 ping statistics --- 3153 packets transmitted, 3153 received, 0% packet loss, time 3154312ms rtt min/avg/max/mdev = 114.975/124.705/139.692/2.004 ms