Free accounts cannot connect out of PythonAnywhere except using http(s) through the proxy. So database connections will not work from a free account. If you upgrade to a paid account, that restriction is removed.