Question

502 Bad Gateway on my site.

Posted October 19, 2021 172 views
Nginx

Hi,

502 Bad Gateway on my site gazda.md, I dont know what to do, nginx its running, logs its clear.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @gazdamoldova,

Have you check error.log?

$ sudo tail -20 /var/log/nginx/error.log

Also check that the nginx configuration is correct:

$ nginx -t

How is it developed? Laravel, Rails, Django… I wait your answer :)

Cheers,
Sergio Turpín

  • @sergioturpin error.log

    2021/10/19 15:44:15 [warn] 709#709: conflicting server name "gazda.md" on 46.101.132.239:80, ignored
    2021/10/19 15:49:12 [warn] 1016#1016: conflicting server name "www.gazda.md" on 46.101.132.239:80, ignored
    

    nginx -t

    [root@centos-s-1vcpu-2gb-fra1-0 ~]# nginx -t
    nginx: [warn] conflicting server name "www.gazda.md" on 46.101.132.239:80, ignored
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    

    Laravel

    • In the /etc/nginx/sites-enabled, it may have left a temp file e.g. default~ (watch the ~).

      Just run $ ls -lah to see which files are unintended to be there and remove them.

      Delete this file and restart nginx.

      Hope helps you,
      Sergio Turpín

      • I dont have a default file after run ls -lah

        [root@centos-s-1vcpu-2gb-fra1-0 ~]# ls -lah
        total 14M
        dr-xr-x---.  9 root root 4.0K Oct 16 20:08 .
        dr-xr-xr-x. 17 root root 4.0K Oct 16 20:06 ..
        -rw-------.  1 root root 6.8K Jan 28  2019 anaconda-ks.cfg
        -rw-------.  1 root root  11K Oct 19 18:11 .bash_history
        -rw-r--r--.  1 root root   18 Dec 29  2013 .bash_logout
        -rw-r--r--.  1 root root  220 May 22  2019 .bash_profile
        -rw-r--r--.  1 root root  176 Dec 29  2013 .bashrc
        drwxr-xr-x.  3 root root   22 May 22  2019 .cache
        -rw-r--r--.  1 root root    0 Apr 13  2021 .cloud-locale-test.skip
        drwxr-xr-x.  3 root root   22 May 22  2019 .config
        -rw-r--r--.  1 root root  100 Dec 29  2013 .cshrc
        -rw-r--r--   1 root root  14M Oct 16 20:08 dump_database_admin_gazda.sql
        -rw-r--r--   1 root root 1.1K Oct 16 18:57 gazda1.com.csr
        -rw-r--r--   1 root root 1.7K Oct 16 18:57 gazda1.com.key
        -rw-r--r--   1 root root   62 Jun 17  2020 .gitconfig
        drwxr-xr-x.  3 root root   19 May 22  2019 .local
        -rw-------.  1 root root   32 May 22  2019 .my.cnf
        -rw-------.  1 root root 6.5K Jan 28  2019 original-ks.cfg
        drwxr-----.  3 root root   19 May 22  2019 .pki
        -rw-------.  1 root root 1.0K Oct 16 18:56 .rnd
        drwx------.  2 root root    6 May 23  2019 .spamassassin
        drwx------.  2 root root   29 May 22  2019 .ssh
        -rw-r--r--.  1 root root  129 Dec 29  2013 .tcshrc
        drwxr-xr-x.  3 root root   24 May 22  2019 vst_install_backups
        -rw-r--r--.  1 root root  47K May 22  2019 vst-install-rhel.sh
        -rw-r--r--.  1 root root 1.7K May 22  2019 vst-install.sh
        
      • @sergioturpin
        .conf nginx file
        server {
        listen 46.101.132.239:80 default;
        server_name www.gazda.md;

        #access_log  /var/log/nginx/46.101.132.239.log main;
        location / {
            proxy_pass  http://46.101.132.239:8080;
        

        }