Hello @Devanshu Soni thanks for the question and sharing the solution that worked for you.
There are two main reasons why your Flask application initially ran without specifying a port and then suddenly required it.
By default, Flask applications launched with just python application.py
used to run on port 5000. This behavior might have changed in a recent update to Flask or your Python environment. This is a reasonable change as using a specific port avoids conflicts with other applications potentially running on the same machine and port combination.
Secondly, it's possible that your initial configuration (without specifying a port) might have been implicitly relying on a default port setting defined in a web server configuration file (e.g., Apache, Nginx). If this configuration was changed or removed, the default port for Flask wouldn't be automatically picked up anymore.
In a production environment, its good to always specify the port in your startup command (python application.py --port 5000
) to avoid any unexpected behavior due to changes .This ensures your application consistently listens on the intended port.
Hope that helped.
Best,
Grace