Nginx 502 Gateway Error on Template Upload


New Member
Hello! Hopefully this is the right place to post. I am having a hard time with Mailwizz.

I am trying to upload the provided by the default Mailwizz install.
I have my own template and that does not work either.

The problem occurs when -

I upload a template with a ZIP file (regardless of CSS or Minify options toggled)
I try to Save a template with source code > 250 ~ lines (under that it seems to work)

I have checked the error log and this is the error:

2015/05/29 11:58:10 [error] 9962#0: *2892 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 999.999.999.999, server:, request: "POST /mailwizz/customer/index.php/templates/upload HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "", referrer: ""
My setup -

PHP Version 5.4.37
Nginx 1.4.3
Install directory

Nginx config -

pid /var/run/;
worker_processes 2;
error_log /etc/nginx/logs/error.log debug;
worker_rlimit_nofile 768;

events {
    worker_connections 768;
    use epoll;
    multi_accept on;

http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log off;
    ignore_invalid_headers     on;
    sendfile        off;
    tcp_nopush     on;
    tcp_nodelay    on;
    server_tokens  off;
    gzip  off;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    server {
        listen       999.999.999.999:80;
        error_log    /etc/nginx/logs/;
        # access_log   /etc/nginx/logs/;

        # Root data
        root /home/;

        # Error pages
        error_page 404  /404.php;
        error_page 500 502 503  /502.php;
        error_page 504 /504.php;

        client_max_body_size 5M;

        # Favicon Not Found
        location = /favicon.ico {
                access_log off;
                log_not_found off;

        # Robots.txt Not Found
        location = /robots.txt {
                access_log off;
                log_not_found off;

        # Location server
        location /{
                index  index.php home.php index.html index.htm;
                include /etc/nginx/fastcgi.conf;

                # if file exists return it right away
                #try_files $uri $uri/ /index.php;
        ## required for mailwizz
        location ~ .*\.(ico|gif|jpg|jpeg|png|js|css) {

        location /mailwizz/ {
            if (!-e $request_filename){
            #rewrite mailwizz/api/.* /mailwizz/api/index.php;
            rewrite ^(/)?mailwizz/api/.*$ /mailwizz/api/index.php;
            if (!-e $request_filename){
            #rewrite mailwizz/customer/.* /mailwizz/customer/index.php;
            rewrite ^(/)?mailwizz/customer/.*$ /mailwizz/customer/index.php;
            if (!-e $request_filename){
            #rewrite mailwizz/backend/.* /mailwizz/backend/index.php;
            rewrite ^(/)?mailwizz/backend/.*$ /mailwizz/backend/index.php;
            if (!-e $request_filename){
            #rewrite ^(.*)$ /mailwizz/index.php;
            rewrite ^(.*)$ /mailwizz/index.php;
            index  index.html index.htm index.php;
        ## required for mailwizz

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                index  index.php index.html index.htm;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass   unix:/var/run/php-fpm.sock;
                fastcgi_index  index.php;
                #fastcgi_param  APPLICATION_ENV development;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   PATH_INFO    $path_info;
                fastcgi_read_timeout 1800;
                fastcgi_send_timeout 1800;

        # Deny access to .ht* files
        location ~ /\.(ht|svn) {
            deny all;
Please help. I really would like this installed on the same website and not have to purchase new hosting just for Mailwizz.
I have lots of other applications running on the same server without issue (including file upload / large text processing)

I'll keep looking around.
well, it isn't mailwizz either as it runs on nginx just fine even though it's not officially supported.