Forums

[Errno 111] Connection refused only occurs in web app, not in console

Hi, I've got a flask web app that tries to send out an email using GoDaddy's SMTP server starting with the following code s = smtplib.SMTP_SSL('smtpout.secureserver.net',465) If I run this in the console, it works just fine and I can send out the message. When it's run in the web app, it fails with a connection refused.

Any thoughts?

Hold the front page - after writing the rest of my post I had a brainwave. Have you recently upgraded to a paid account? If so, have you tried reloading your web app from the dashboard page? If not, try it now - it may be that your web app is still running in the old free account environment and hence isn't allowed to connect out - your console, presumably having ben created after you upgraded, is fine.

If reloading doesn't work, read my original post below..

Hm, sounds odd - I can't think of much that could be different in the environment between the two to cause a TCP connection to be refused. You're definitely getting a socket level connection refused exception as opposed to an SMTP error of some description? If you're in any doubt it might be helpful to post the precise exception. I'm sure you're right, but there are a suprising number of very similar-sounding errors, the exact nature of which may provide clues to the underlying cause.

So assuming it is a connection refused, I can only assume that your web app and console are running on different hosts and either there's something like a firewall issue PA-side, or the remote end is blocking one of the hosts for some reason and not the other.

Perhaps the admins can step in with some thoughts.

Yeah, it was that I hadn't reloaded the app after upgrading. Thanks a lot!

Phew!