Forums

Connection refused to PostgreSQL server

Hi,

As PostgreSQL is not yet available, I had set-up a server in Heroku. I'm able to access the server (hosted by Amazon AWS) from PGAdmin3 from my own computer.

I'm getting a "Connection refused" error when SQLAlchemy attempts to connect to the server:

OperationalError: (OperationalError) could not connect to server: Connection refused Is the server running on host "ec2-54-197-249-167.compute-1.amazonaws.com" (10.151.78.254) and accepting TCP/IP connections on port 5432?

Is this a connection issue in PythonAnywhere or is this a limitation (of free accounts)? I wanted to demo an application to my boss to get a business case running. I would be a paying user if I can get the database connection working. Thanks.

That will be because you have a free account which doesn't offer unrestricted Internet access. You will need to either (a) pay $5 for a hacker account, or (b) host your Postgres server somewhere on the PythonAnywhere whitelist

I'm in the impression that it's an issue because .amazonaws.com is listed on the whitelist. Unless of course if it is the port that's restricted.

This is a great service but would be better if PostgreSQL is supported (whitelisting port 5432). For the same $5, a VPS in DigitalOcean is a competition.

Yes; Digital Ocean and Linode are both excellent services. I use them to host Asterisk servers and VPN servers (to escape geoblocking). But if I want to build host a Flask app, and not worry about scaling, reliability, or updating Linux or mySQL then PythonAnywhere is the easy option :-)

Well, it took a long amount of time to get right... but Postgres support is now live!

You'll need to sign up for a custom plan (with the Postgres option enabled) to get it. To do that:

  • If you already have a custom plan, you just need to go to the Account page, and click on the "Change your custom plan" button. The popup window will be pre-configured with all of your current custom plan settings, so you just need to switch the Postgres option on, choose how much disk space you want for your PG databases, and then click "Switch to this custom plan". This will take you through the normal payment confirmation process.
  • If you have a Hacker, Web Dev, or Startup account it's a little more complicated -- you can go to the Account page and click on the "Build a custom plan" button, but right now, the popup won't be initialised with your current account's settings (we're working on a fix for this). So you'll need to set the sliders to match those as well as switch on Postgres -- I've included a table of the correct settings below. Once you've configured a custom plan with your settings and with Postgres enabled, you can click on "Switch to this custom plan" and do the payment confirmation. Sorry for the inconvenience -- we only realised that this annoyance was there right at the end of development and we didn't want to delay the Postgres release while we tinkered with the UI.

Let us know if you have any questions!

Here are the settings for the Custom plan popup to mimic the non-custom plans:

|                        | Hacker | Web Developer | Startup |
|------------------------|--------|---------------|---------|
| CPU time per day:      | 3000   | 3000          | 50000   |
| Number of web apps:    | 1      | 3             | 8       |
| Number of web workers: | 2      | 3             | 5       |
| Disk space (GB):       | 0.5    | 5             | 50      |