how can I run flask app in different port?


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__':, host='', port=8000)

but it doesnt change anything.
also I use


so I run app via flask run


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.

Answered By – MarcusWilliams

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published