A user (pr0cesor) encountered a 502 Bad Gateway error due to nginx failing to connect to /var/discourse/shared/standalone/nginx.http.sock, indicating the socket file was missing. They shared their discourse.conf and app.yml configurations, noting they had tried enabling web.socketed.template.yml without success. Arkshine suggested ensuring SSL/Let’s Encrypt templates are commented (since SSL is handled externally) and rebuilding the app to generate the socket file — which resolved the 502 error for pr0cesor, though SSL and image loading issues persisted. Arkshine then advised enabling the “force HTTPS” option in Discourse’s security settings, which fully resolved the issue — prompting pr0cesor to express gratitude. Later, another user (Mednosis) reported the same 502 error despite following the advice, with no HTTPS in use, and shared their identical discourse.conf and app.yml — suggesting the solution may not be universal or that a rebuild was missed. The core fix involves proper template configuration, rebuilding the Discourse container, and ensuring the socket file is generated.
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 ;/
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.
OMGGG!!! Thannnnnkkk uuuuu <3 . I owe u a some fruits .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,