I have configured php-fpm, and nginx for development under a home folder, and I've been unable to resolve a permissions issue. It appears that php7.1-fpm.sock still refuses a connection, even though all permissions appear to be correct.


root@xps:/var/log/nginx# cat error.log 
2017/05/29 00:41:23 [crit] 27326#27326: *1 connect() to unix:/run/php/php7.1-fpm.sock failed (13: Permission denied) while connecting to upstream, client:, server: sub.tld.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "sub.tld.com"

This occurs every time I attempt to access the web root, which should display:

<?php echo phpinfo(); ?> 

in a browser window.


user darin darin;

sub.tld.com.conf for nginx

server_name sub.tld.com
root /home/darin/www
location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;

www.conf for php-fpm

user = darin
group = darin
listen = /run/php/php7.1-fpm.sock
listen.owner = darin
listen.group = darin
listen.mode = 0660

It appears that /run/php is a symbolic link to /var/run/php. Maybe this is intended to simplify configuration. I'm not sure, but pointing the socket file to /var/run/php and /run/php should work.

root@xps:/etc/nginx/conf.d# ls -l /var/run/php/
total 4
-rw-r--r-- 1 root  root  4 May 29 14:33 php7.1-fpm.pid
srw-rw---- 1 darin darin 0 May 29 14:33 php7.1-fpm.sock

root@xps:/etc/nginx/conf.d# ls -l /run/php/
total 4
-rw-r--r-- 1 root  root  4 May 29 14:33 php7.1-fpm.pid
srw-rw---- 1 darin darin 0 May 29 14:33 php7.1-fpm.sock

nginx processes

ps aux | grep nginx
root      5489  0.0  0.0  31884   880 ?        Ss   14:33   0:00 nginx: 
master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
darin     5490  0.0  0.0  32308  3536 ?        S    14:33   0:00 nginx: worker process

fpm processes

ps aux | grep fpm
root      5535  0.0  0.7 642880 60172 ?        Ss   14:33   0:00 php-fpm: master process (/etc/php/7.1/fpm/php-fpm.conf)                      
darin     5537  0.0  0.1 642880 12472 ?        S    14:33   0:00 php-fpm: pool www                                                            
darin     5563  0.0  0.1 642880 12472 ?        S    14:33   0:00 php-fpm: pool www 

I read loads of configuration posts, and the configuration files appear to be correct. There was one post that indicated I needed to change permissions of /var/lib/nginx, so darin:darin owns this, but I do not find a /var/lib/nginx file or folder.

  • It's probably simpler to use sockets to talk to PHP rather than work out the unix:// stuff. However, I wonder if the sock file needs execute access - not sure, but worth double checking. Also check the PHP / PHPFPM error logs.
    – Tim
    May 29 '17 at 21:00
  • 1
    What permissions you have on directory /run/php ? May 29 '17 at 21:05
  • The permissions on /run/php are: drwxr-xr-x 2 www-data www-data 80 May 29 14:33 php. I changed this to darin:darin, and i'm still getting the error after restarting nginx and php7.1-fpm, but it's a different error: "2017/05/29 13:55:35 [error] 29293#29293: *10 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:, server: sub.tld.org, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "sub.tld.org"" May 29 '17 at 21:13
  • The php7.1-fpm.log file indicates connection issues too: WARNING: [pool www] child 8663 exited on signal 6 (SIGABRT) after 2.678027 seconds from start [29-May-2017 15:10:44] NOTICE: [pool www] child 8689 started. I'm unsure how to resolve these issues. I'm not finding a lot of information about this... May 29 '17 at 21:51
  • How did you install 'php7'?
    – AlexD
    May 29 '17 at 22:38

Move answer from comments

There was wrong premissions on /run/php

drwxr-xr-x 2 www-data www-data 80 May 29 14:33 php

To correct the problem, the permissions on /run/php were changed to match the nginx user:

chown darin:darin /run/php

After correcting the permissions issue, was still getting an application error when attempting to access the index.php page.

One of the following packages was causing the problem: "libphp7.1-embed php-apcu php-ds php-gearman php-geoip php-gmagick php-igbinary php-imagick php-mailparse php-http php-memcache php-memcached php-msgpack php-oauth php-radius php-redis php-rrd php-stomp php-tideways php-uploadprogress php-uuid php-xdebug php-yaml".

After removing, purging and reinstalling php7.1 modules needed, it's working as expected..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.