Nginx: configuration file /etc/nginx/nginx.conf test failed

My YunoHost server

Hardware: Raspberry Pi400
YunoHost version: 11.2.10
I have access to my server : Through SSH
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Hello Yunohost guys,
i got a very similar problem like here
Re-create nginx .conf file .
My nginx config is broken.

the command ; nginx -t shows:
nginx: [emerg] invalid port in upstream “localhost:” in /etc/nginx/conf.d/mqtt.2
nginx: configuration file /etc/nginx/nginx.conf test failed

I tried :
yunohost service regen-conf nginx --dry-run -d
yunohost service regen-conf nginx --force

but this shows an yunohost service: error .
It looks like “yunohost service regen-conf” doesent work at all.

i also found and tried the command
yunohost tools regen-conf nginx --dry-run -d
yunohost tools regen-conf nginx --force

This shows no error but did not solve the problem.
nginx configuration is still broken.

So im out of glue and looking for help.
How to restore nginx config?

nano /etc/nginx/conf.d/ shows this :

upstream {
server localhost:;

map $http_upgrade $connection_upgrade {
default upgrade;
‘’ close;

server {
listen 80;
listen [::]:80;

access_by_lua_file /usr/share/ssowat/access.lua;

include /etc/nginx/conf.d/;

location ^~ '/.well-known/ynh-diagnosis/' {
    alias /var/www/.well-known/ynh-diagnosis/;Read 83 lines ]

nano /etc/nginx/conf.d/ shows :

location / {

#Settings for mqtt server from outside
proxy_http_version 1.1;
proxy_read_timeout 90;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;


Have you tried to do nginx -t to see where nginx complains?

Yes, i tried already.
nginx -t shows:
nginx: [emerg] invalid port in upstream “localhost:” in /etc/nginx/conf.d/mqtt.2
nginx: configuration file /etc/nginx/nginx.conf test failed

What’s inside that file? What’s the app that domain pointing to?

you need to put a port number after the :

Thank you all, i got a solution.
Deinstall of mosquitto and deleting all the mqtt files in the /etc/nginx/conf.d directory helped. Then reboot and nginx service was up again… after this i could do a clean install of mosquitto .
Best wishes from Germany


great news :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.