简体   繁体   中英

Nginx error when trying to deploy flask server

I am trying to follow this guid to deploy a flask server: https://medium.com/ymedialabs-innovation/deploy-flask-app-with-nginx-using-gunicorn-and-supervisor-d7a93aa07c18

I followed all the steps except the supervisor part which I fully skipped because the command wouldn't work, but it should not matter just to get things working.

When I run: sudo nginx -t

I get: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

What is teh issue? I have seen other people getting this error but the solutions don;t seem to work for me?

This is my nginx conf file:

server {
    listen   80;
    server_name  <name>;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

#server {
#    listen   8000;
#    listen   somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

And the python flask server:

from flask import Flask
from flask import render_template
from flask import send_file

app = Flask(__name__, static_url_path="/static", static_folder="/static")
app.static_folder = 'static'

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/uploads/resume")
def download_resume():
    return send_file("static/documents/resume.pdf")

if __name__ == '__main__':
    app.run(port=5010, debug=False, host='0.0.0.0')
  • Go to /etc/nginx/sites-available/default
  • Disable IPV6

I just commented out the following line

listen [::]:80 default_server ipv6only=on;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM