dev5
By:
dev5

nginx error “page is temporarily unavailable”

July 18, 2017 366 views
Python Nginx CentOS

I've SSH installed a Python 3.5 application on CentOS along with uwsgi and nginx, but after doing asudo vi /etc/nginx/nginx.conf to edit the nginx config file as per usual, the response is currently:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

these are the contents of the /etc/nginx/nginx.conf file:

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

include /etc/nginx/conf.d/*.conf;

server {
    listen      [::]:80 default_server;
    server_name  _;
    root         /var/www/html/<directory//;

    location / {
    }

The server is currently showing an nginx error page

4 Answers

Hi @dev5

Can you run sudo nginx -t or sudo service nginx configtest to test your configuration.
And then post the last 30 lines from the error log also:

tail -30 /var/log/nginx/error.log

@dev5

Uhm, but your Nginx has server_name localhost; which means it's only accessible from the server itself.
Can you post your entire Nginx site configuration and your entire uWSGI?
And I would recommend that you do not have any server blocks in your main Nginx configuration located in /etc/nginx/nginx.conf

[deleted]
  • Config test was completed successfully with no syntax errors.

    2017/07/18 15:34:04 [crit] 2829#0: *41 connect() to unix:/var/www/html/pricing-service/socket.sock failed (2: No such file or directory) while connecting to upstream, client: 90.63.208.189, server: localhost, request: "HEAD http://178.62.201.111:80/phpmyadmin2013/ HTTP/1.1", upstream: "uwsgi://unix:/var/www/html/pricing-service/socket.sock:", host: "178.62.201.111"
    
    • @dev5

      But is the socket location in uWSGI the same as in Nginx?

      /var/www/html/pricing-service/socket.sock
      
      • [Nginx]

        server {
            listen 80;
            real_ip_header X-Forwarded-For;
            set_real_ip_from 127.0.0.1;
            server_name localhost;
        
        location / {
            include uwsgi_params;
            uwsgi_pass unix:/var/www/html/pricing-service/socket.sock;
            uwsgi_modifier1 30;
            }
        

        [uWSGI]

        [uwsgi]
        #application's base folder
        base = /var/www/html/pricing-service
        
        #python module to import
        app = src.app
        module = %(app)
        
        home = %(base)/venv
        pythonpath = %(base)
        
        #socket file's location
        socket = /var/www/html/pricing-service/socket.sock
        
  • [deleted]

/etc/nginx/nginx.conf file:
https://jpst.it/11K8f

and `/etc/init/uwsgi.conf config file:
https://jpst.it/11K8T

  • @dev5
    But there's no uwsgi_pass in that Nginx configuration. That's just your main Nginx configuration. And the main Nginx configuration should not have any server blocks. And it looks like there's multiple server blocks with the same information - all of them incorrect.
    Your server blocks should be located in separate files in /etc/nginx/default.d/*.conf

Have another answer? Share your knowledge.