Home > OS >  how can I run flask app in different port?
how can I run flask app in different port?

Time:08-15

I have a issue, problem is when I run flask app port :5000 it stops becouse: Port 5000 is in use by another program. Either identify and stop that program, or start the server with a different port. but I dont know when i use it. I change port by :

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=8000)

but it doesnt change anything. also I use

export FLASK_APP=run.py 

so I run app via flask run

CodePudding user response:

There are a couple of options that might help.

If you are running your app using the flask run command in the terminal try adding this to the command

flask run -h localhost -p 8000

Another thing that might help is setting the run port in the environment variables like this

export FLASK_RUN_PORT=8000

Let me know if either of these work.

  • Related