Postgres connection error

Hi,

I’m deploying my app and i get an error related to postgres connection, error is :slight_smile:

psycopg2.OperationalError: could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5433?

before that, the Travis log says


/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/django/db/backends/postgresql/base.py:270: RuntimeWarning: Normally Django will use a connection to the 'postgres' database to avoid running initialization queries against the production database when it's not needed (for example, when running tests). Django was unable to create a connection to the 'postgres' database and will use the first PostgreSQL database instead.

as i’m using Pipenv i did create a .travis file like below :slight_smile:

language: python
python:
  - '3.6.7'

# safelist
branches:
  only:
    - staging

services:
  - postgresql

env: DJANGO_SETTINGS_MODULE=purbeurre.settings.travis

before_install:
  - sudo service postgresql stop
  - sed -e 's/^port.*/port = 5433/' /etc/postgresql/10/main/postgresql.conf > postgresql.conf
  - sudo chown postgres postgresql.conf
  - sudo mv postgresql.conf /etc/postgresql/10/main
  - sudo service postgresql start 10

install:
  - make init
script:
  - make test

and the corresponding Makefile :slight_smile:

help:
	@echo '    init'
	@echo '        install pipenv and all project dependencies'
	@echo '    test'
	@echo '        run all tests'

init:
	@echo 'Install python dependencies'
	pip install pipenv
	pipenv install

test:
	@echo 'Run all tests'
	pipenv run python manage.py test

Can you help understand this error and help me to fix it ?

Possible duplicate of