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/mqtt.1a.noho.st.conf shows this :

upstream mqtt.1a.noho.st {
server localhost:;
}

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

server {
listen 80;
listen [::]:80;
server_name mqtt.1a.noho.st;

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

include /etc/nginx/conf.d/acme-challenge.conf.inc;

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

nano /etc/nginx/conf.d/mqtt.1a.noho.st.d/mqtt_domoticz.conf shows :

location / {

#Settings for mqtt server from outside
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8883;
proxy_read_timeout 90;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;
}

Hi!

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

2 Likes

great news :slight_smile:

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