Unix:/var/discourse/shared/standalone/nginx.http.sock (2: No such file or directory) [SOLVED]

Hi everyone,

I got a 502 Bad Gateway on my website and I can’t get pass this issue with nginx.http.sock

Nginx error.log

[crit] 14339#14339: *1 connect() to unix:/var/discourse/shared/standalone/nginx.http.sock failed (2: No such file or directory) while connecting to upstream, client: **.***.***.***, server: mydomain.net, request: "GET / HTTP/2.0", upstream: "http://unix:/var/discourse/shared/standalone/nginx.http.sock:/", host: "mydomain.net", referrer: "https:/mydomain.net/" "

Below my discourse.conf

server {
    listen 80;
    listen [::]:80;
    server_name mydmain.net www.mydomain.net;  # <-- change this

}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name mydomain www.mydomain.net;  # <-- change this

    ssl on;
    ssl_certificate /etc/letsencrypt/live/mydomain.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mydomain.net/privkey.pem; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/live/mydomain.net/dhparams.pem;
    include /etc/nginx/snippets/ssl.conf;

    http2_idle_timeout 5m; # up from 3m default

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;

    }
}

My app.yml

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"
##  - "templates/web.socketed.template.yml"
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
#expose:
# - "2045:80"   # http
# - "1443:443" # https

I tried to uncomment “templates/web.socketed.template.yml” as well but same result in the Nginx error log. What should I do to solve this problem? I ran out of idea. Please help ;/

1 Like

I’m not an expert, and unless I’m wrong, if you go with the socket way, you likely need to uncomment web.socketed.template.

1 Like

Hey, I already did that and have the same result.

1 Like

Just tried on my installation (was using the other way with listening a port) and it works.

You need to make sure that:

  • SSL/Let’s Encrypt templates are commented because it’s already handled by your external Nginx config.
  • Rebuild the app so the nginx.http.sock file will appear in /var/discourse/shared/standalone/
5 Likes

Make sure

  • SSL/Let’s Encrypt templates are commented because it’s already cared by your external Nginx config.
  • Rebuild the app so the nginx.http.sock file will appear in `/var/discourse/shared/standalone/

Okay, but what will happen about this line then? The 502 gateway error is gonne and the website is up, however I see the same nginx error because of this line.

location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;

SSL seems not to be working and the images are not displayed. I uploaded a logo when setting up the forum

sssl_notsecure

2 Likes

If not already done, try to enable the force https discourse option (security tab)

4 Likes

OMGGG!!! Thannnnnkkk uuuuu <3 . I owe u a some fruits :smiley: .N w I have to figure out how to make SMTP work cause with Yandex it didn’t work and I don’t receive any email when registering test users,

3 Likes

I tried all above suggestion but still getting 502 bad gateway error. For now i am not using HTTPS.

Following is my error:

> 2020/04/02 00:17:54 [crit] 18599#18599: *1 connect() to unix:/var/discourse/shared/standalone/nginx.http.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xxx.xxx.xx, server: talk.mydomain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/discourse/shared/standalone/nginx.http.sock:/", host: "talk.mydomain.com"
> 
> 2020/04/02 00:17:54 [crit] 18599#18599: *1 connect() to unix:/var/discourse/shared/standalone/nginx.http.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xxx.xxx.xx, server: talk.mydomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/var/discourse/shared/standalone/nginx.http.sock:/favicon.ico", host: "talk.mydomain.com", referrer: "http://talk.mydomain.com/"

Following is my /etc/nginx/sites-enabled/discourse.conf file:

server {
        listen 80; listen [::]:80;
        server_name talk.mydomain.com;
        location / {
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
        }
}

Following is the template section of /var/discourse/containers/app.yml:

server {
        listen 80; listen [::]:80;
        server_name talk.mydomain.com;
        location / {
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
        }
}

Please advise.

1 Like