What I've done so far,

Installed nginx 1.19.6 Installed php 7.4 and all required extensions in Magento Documentation Installed and configured MySQL as per documentation, and created magentodb Installed Elasticsearch 7.x (Success) Installed Redis-server (Success) DID NOT install Varnish since the Magento documentation states that it does not support SSL and I can't run my magento store without SSL.

Downloaded Magento 2.4.1 Community edition with sample data Moved to the chosen root directory @ /var/www/

Created Non-root sudo user, and carefully provided all the necessary permissions.

Usually, I get a magento welcome page like this one: enter image description here

But this time, i rebuilt my whole droplet making sure i didn't miss any of the details that caused me errors before. This time I'm getting an "Unable to connect" error in my browser, and sending a GET request from terminal is returning the below error.

curl -XGET 'https://mydomain/'

curl: (7) Failed to connect to mydomain port 443: Connection refused

ping to mydomain successfully points to my cloud IP address

PING mydomain (ipv4-xxx-xx-xxx) 56(84) bytes of data.
64 bytes from ipv4-xxx-xx-xxx (ipv4.xxx.xx.xx): icmp_seq=1 ttl=53 time=167 ms

GET Request to my localhost on my server successfully returns the Nginx welcome page:

 curl -XGET 'localhost'
<!DOCTYPE html>
<title>Welcome to nginx!</title>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;

Does anyone have a hint where to go from here?


Update: I am running Magento 2.4.1 Community Edition

Nginx Status

Active: active (running) since Fri 2021-01-22 19:26:03 UTC; 15h ago

Nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 

PHP7.4-FPM status

Active: active (running) since Fri 2021-01-22 18:49:59 UTC; 16h ago 

Didn't install varnish since the Magento Docs state that it doesn't support SSL.

Yes my configuration file is symlinked to /sites-enabled/

This is my /sites-available/* config file

upstream fastcgi_backend {
        server  unix:/run/php/php7.4-fpm.sock;

server {
    listen 80;
    listen [::]:80;
    server_name mydomain;
    return 301 https://$server_name$request_uri;

server {

        listen 443 ssl;
        server_name mydomain;

        ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;

        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE default;
        include /var/www/magento2/nginx.conf.sample;

Also, I have UFW enabled with the following allowed connections

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 443/tcp                    ALLOW IN    Anywhere                  
[ 2] 22/tcp                     ALLOW IN    Anywhere                  
[ 3] 443/tcp (v6)               ALLOW IN    Anywhere (v6)             
[ 4] 22/tcp (v6)                ALLOW IN    Anywhere (v6)  

1 Answer 1


Debug advices first:

  • can u run sudo systemctl status nginx
  • can u run sudo systemctl status php7.x-fpm # hint: replace x with your php version
  • Is varnish enabled and which version of varnish do you use?
    sudo varnishd -V
    sudo systemctl status varnish
  • which magento2 version are u running?

Please provide your configurations located in: /etc/nginx/sites-available/<<your conf file>>

Is your conf file available in /etc/nginx/sites-enabled/<<your conf file>>

I installed Magento 2.4.x and 2.3.x a lot of times and can give u a lot of really detailed instructions that you can follow. Just ask me ;)

UPDATE 24.01.2020 23:00:00:


First of all: Your questions is really really general and can have different problems at different locations. Of course it is possible to use varnish cache with ssl. You can add varnish as a reverse proxy between nginx server ports. It is really recommend to use varnish because otherwise Magento2 is so slow. You will use important conversion rate and loose also customers because everything will take so long...

One example is this website that I am working on. It uses nginx webserver, varnish cache 6 (varnish cache 5 caused a lot of problems ob Ubuntu 18.04) and also an automatic cache warmer (auto crawler for my website)

I followed these instructions:


I think that you have maybe some path failures and maybe also permission problems.

  • Replace all 7.3 with 7.4 when using magento 2.4.x
  • Replace goldschmiede-jaqueline with yourdomain

If u run one store without any different domains/subdomains then your folder should approximately like the following picture:

enter image description here

Inside etc/nginx/sites-available/goldschmiede-jaqueline.de

upstream fastcgi_backend {
     server  unix:/run/php/php7.3-fpm.sock;

server {
    server_name goldschmiede-jaqueline.de www.goldschmiede-jaqueline.de;

    # root /var/www/goldschmiede-jaqueline.de;
    # index index.php index.html;

    set $MAGE_ROOT /var/www/goldschmiede-jaqueline.de;
    include /var/www/goldschmiede-jaqueline.de/nginx.conf.sample;

    #location ~ \.php$ {
    #   fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    #   include snippets/fastcgi-php.conf;
    #   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # }

server {
    listen 80;
    server_name goldschmiede-jaqueline.de www.goldschmiede-jaqueline.de;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

    location ~ [^/]\.php(/|$) {
        fastcgi_cache phpcache; # The name of the cache key-zone to use
        fastcgi_cache_valid 200 30m; # What to cache: 'Code 200' responses, for half an hour
        fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (not POST)
        add_header X-Fastcgi-Cache $upstream_cache_status; # Add header so we can see if the cache hits or misses

        # the rest of your existing stuff to handle PHP files here

    return 301 https://goldschmiede-jaqueline.de$request_uri;

server {
    listen 443 ssl http2;
    server_name goldschmiede-jaqueline.de www.goldschmiede-jaqueline.de;

    access_log /var/log/nginx/goldschmiede-jaqueline-access.log;
    error_log /var/log/nginx/goldschmiede-jaqueline-error.log;

    ssl_certificate /etc/letsencrypt/live/goldschmiede-jaqueline.de/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/goldschmiede-jaqueline.de/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    ssl_stapling on;
    ssl_stapling_verify on;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Ssl-Offloaded "1";
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;
        proxy_redirect  http://goldschmiede-jaqueline.de:8080/  /;
        proxy_http_version 1.1;

Inside /etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;

http {

    # Basic Settings

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # SSL Settings

    # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    # ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_buffer_size 8k;
    ssl_session_cache shared:SSL:1m; # holds approx 4000 sessions
    ssl_session_timeout 24h; # 1 hour during which sessions can be re-used.
    ssl_session_tickets off;

    # Logging Settings

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Gzip Settings

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    # Virtual Host Configs

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    fastcgi_cache_path /etc/nginx-cache levels=1:2 keys_zone=phpcache:100m inactive=60m;
        fastcgi_cache_key "$scheme$request_method$host$request_uri";

#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }

Your path to magento2 root should look like that:

enter image description here

  • Get sure that your user have enough permissions.
    sudo chmod 755 /var/www

  • Please enable port 80 as well - use this script in your shell-

sudo ufw default deny incoming && \
sudo ufw default allow outgoing && \
sudo ufw allow ssh && \
sudo ufw allow http && \
sudo ufw allow https && \
echo "y" | sudo ufw enable

If u have problems contact me directly over [email protected] and we can do a teams call or sth. similiar :P

  • Hello, i Updated the original post please check it thanks!
    – SRM92
    Jan 23, 2021 at 11:40
  • Hi I updated the answer. U can contact me directly per Mail when you have questions. [email protected] Jan 24, 2021 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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