Serving apps on subdomains with flask/apache works and then... not so much

At this point, this has gotten fairly automatic. I can create a flask/python app, test it on my laptop, copy it up to my linode host, setup/fill the database, launch the app with 'python -m flask run --host=0.0.0.0.0 --port=PORT', verify that that works great, add the bits to my 'SUBDOM-le-ssl.conf' file (where the 5 apps are already running just fine), restart apache and … sometimes it works. Not really. It does not work.

I have 5 working deployments. I can copy and paste the block for a working app, change just the names that need to change, verify all of the paths are there and all the files are there and … Nope.

Either it says something is forbidden and I cannot find any file or path with bad permissions (permissions different than the one right next to it, which works) or it says 'Cannot find path', which seems to be a flask error and I see nothing in the apache logs.

There are many things I could be doing wrong. But I do them all right 3 or 4 times and then horribly wrong every time after that? What? How is that possible?

So, should I just give up on apache? Is flask+nginx a better solution? This does not seem as if it is rocket science. So why the heck is it so fragile?

1 Reply

I don't have much experience with using Flask, but it'd be easier to help point you in the right direction if you were able to provide some specific error codes that were outputted. That said, based on the error 'Cannot find path`, there are similar posts where other users countered the same issue. In this StackOverflow post, it was mentioned that this situation can occur when you have an ImportError that has not propagated through to your terminal. It was recommended that you review all of your files for invalid import statements, fix them, and the error should disappear.

This other post mentions that you need to use the actual filename that your file is stored as. If you use a different filename, then it will not find it. It also states, if you're using some sort of library to load the files, perhaps the library has some code that make assumptions about file extensions and automatically adds it it some cases. It's recommended that you check the documentation for the library to see if there were anything mentions about it. Additionally, you may find these other posts regarding the same issue useful:

In regards to the Forbidden error, it usually indicates an issue with the permissions on a file or the user lacks the necessary privileges to access, modify, or execute a particular file or directory. It doesn't hurt to check your permissions again just in case:

Lastly, you may be interested in joining Flask's discord as there may be knowledgable users who can assist further with your configuration and complex errors. There's also an error logging tool, such as Sentry that you can use to troubleshoot Flask. Sentry aggregates duplicate errors, captures the full stack trace and local variables for debugging, and sends you mails based on new errors or frequency thresholds. If you'd like to learn about this tool, I recommend the following guides:

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct