Bad Gateway 502 (socket problem)

After a clean install on a ubuntu 12.04 the Virtualmin + Nginx runs ok, but as soon as i make an change on een users virtual server, eg add phpmyadmin, or add script roundcube the website is down: ban gateway 502

As far i can see there is no socket in /var/php-nginx

in logfile: PHP Warning: Module 'mcrypt' already loaded in Unknown on line 0 Cannot bind/listen socket - [2] No such file or directory. Couldn't create FastCGI listen socket on port /var/php-nginx/13689748061364.sock/socket

starting the php for the user does not change anything.

When i create a new virtual server, php for that server is ok, but as soon i make a change, php does not start anymore.

I was thinking about trying the Pro, but there is no demo, down for weeks i think, and i do not know if things are working in Pro

anyone ?



We've had to shut down the demo temporarily as someone was abusing it to send spam :-( It wouldn't help you much in this case though, as it runs Apache and not Nginx.

Regarding your Nginx problem, it sounds like the php-cgi processes for the domain are exiting. If you run ps auxwww | grep XXX where XXX is the domain's username, what processes does it show?

Hi Jaimie,

ps aux shown only:

root 14512 0.0 0.1 9384 884 pts/0 S+ 05:56 0:00 grep --color=auto voorbeeld

but that makes sense :)

when i create a new virtual host (virtual domain) is does show the fcgo process but as soon as i eg add phpmyadmin or any thing else to the virtual domain throught virtualmin, things gets messed up i guess and the process is gone. Cannot start it up either.

root@d2:~# ls -l /var/php-nginx/ total 8 -rw-rw-r-- 1 test test 6 May 19 17:39 -rw-r--r-- 1 voorbeeld voorbeeld 6 May 19 17:39

but no socket ...

gr. Conrad Maayen

in webmin:

php-fcgi-test-nl Start Nginx PHP fcgi server for Yes Unknown php-fcgi-voorbeeld-nl Start Nginx PHP fcgi server for Yes Unknown

Do you ever seen the process running as the domain user? That is what is supposed to restart crashed PHP processes.

ps aux | grep php root 6515 0.0 0.1 9384 884 pts/0 S+ 06:27 0:00 grep --color=auto php test 6711 0.0 0.3 23232 1940 ? S May19 0:17 /usr/bin/perl /usr/bin/ /usr/bin/php5-cgi -b /var/php-nginx/136891176415813.sock/socket test 16249 0.0 0.4 26092 2028 ? S May19 0:14 /usr/bin/perl /usr/bin/ /usr/bin/php5-cgi -b /var/php-nginx/136891176415813.sock/socket 1001 16262 0.0 0.4 26092 2032 ? S May19 0:15 /usr/bin/perl /usr/bin/ /usr/bin/php5-cgi -b /var/php-nginx/13689748061364.sock/socket

btw /var/php-nginx = 777

Other thing: Like virtualmin and i was thinking about using virtualmin as a replacement for my current panels, but i'm worried about the paid support which comes with the license. When there is a bug or problem with virtualmin, how fast am i getting support..... and there is the timezone issue....

Ok, that ps output looks good. I'm mystified as to why the php processes would be exiting and not beign re-started.

Would it be possible for us to login to your system and see what is going wrong? Email me directly at if so.

Thanks Jamie,

just emailed you.

Ok, the cause was missing domain directories under the /var/php-nginx directory. I'm not sure how this happened though, as creating a new domain does create the required directory OK.

Hi Jamie

This issue happen again with the latest virtualmin/nginx debian install.

I had to manually create the domain directory in /var/nginx-php

Best regards.


roberto - was this a fresh install on a new system?

Hi Jamie

Yes was a fresh install in a Debian 7 server.

I've create the directory:


manually and it was fixed.


Ok, it looks like we haven't actually released the fixed Nginx plugin yet.

Ok, Jamie. I can test it when you release the new fixed version.


I just added php my admin to a site and experienced this same issue. I recreated the .sock directory for the site to correct it.