Domain not serving wsgi file, but the IP does


I’m trying to deploy a flask application on my droplet, which is running ubuntu, but every time I change my virtual host file to the domain, it just serves the index of /var/www/html and not the wsgi which I specified in the virtual host file. However, if I use my droplet’s IP for “ServerName”, it works fine.

Any ideas?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Like I was saying, the virtual host file works with the IP, but not the domain. Here it is though:

<VirtualHost *>
		WSGIScriptAlias / /var/www/html/Training/training.wsgi
		<Directory /var/www/html/Training/Training/>
			Order allow,deny
			Allow from all
		Alias /static /var/www/html/Training/Training/static
		<Directory /var/www/html/Training/Training/static/>
			Order allow,deny
			Allow from all
		ErrorLog ${APACHE_LOG_DIR}/error.log
		LogLevel warn
		CustomLog ${APACHE_LOG_DIR}/access.log combined

When I replace “ServerName” with “”, it just displays the folders.

Could you post your Apache VirtualHost? Have you set WSGIScriptAlias ? It should look something like:

<VirtualHost *>

    WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
    WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi

    <Directory /var/www/yourapplication>
        WSGIProcessGroup yourapplication
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all

Also make sure that mod_wsgi is installed:

sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
sudo service apache2 restart

Check out Flask’s docs on using it with Apache.