psql: could not connect to server error on "travis-ci"

Marcelo Toledo

My build is broken on travis-ci:

$ psql -c 'create database travis_ci_test;' -U postgres
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

The command "psql -c 'create database travis_ci_test;' -U postgres" failed and exited with 2 during.

I'm usin this .travis.yml:

Yaml Version updated on 05/31/2020:

dist: trusty

env:
    global:
      - PGPORT=5433

services:
    - postgresql

addons:
    postgresql: '10'
    apt:
        packages:
        - postgresql-10
        - postgresql-client-10

before_script:
    - export RUBYOPT='-W0' # to remove ruby 2.7 warnings
    - cp config/database.yml.travis config/database.yml

language: ruby

rvm:
    - 2.7.0

script:
    - bundle exec rails db:reset db:setup db:migrate
    - bundle exec rspec
    - bundle exec rubocop --config .rubocop.yml

before_install:
    - gem update --system
    - gem install bundler
Marcelo Toledo

EDITED AFTER SOLUTION:

I was able to find out what was wrong. See below the definitive solution:

First: Travis wasn't compactive with postgres-10 (in the past)

Second: I needed remove the line that create a new database.

services:
    - postgresql

addons:
    postgresql: '9.6'

before_script:
    - cp config/database.yml.travis config/database.yml

language: ruby

rvm:
    - 2.5.0

script:
    - bundle exec rails db:reset db:setup db:migrate RAILS_ENV=test
    - bundle exec rspec
    - bundle exec rubocop --config .rubocop.yml

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Travis-CI and PostgreSQL: psql: error: could not connect to server: No such file or directory

How to solve psql error: could not connect to server?

psql: error: could not connect to server: FATAL: password authentication failed for user

Psql could not connect to server: No such file or directory, 5432 error?

docker build error: psql: could not connect to server: Connection refused

"psql: could not connect to server: No such file or directory"

Psql Docker: could not connect to server: No such file or directory

docker-compose psql could not connect to server

"psql: could not connect to server: Connection refused" Error when connecting to remote database

Docker container fails to connect to psql. psql: could not connect to server. docker compose

psql: could not connect to server: No such file or directory (Mac OS X)

Travis CI for Android - Build Error: Failed to find target & Could not find dependencies

Travis CI error importing module

Error with integration in Travis-CI

Can't connect to my AWS Database Instance | psql: could not connect to server: Operation timed out

Prisma Deploy Docker error "Could not connect to server"

postgres_fdw error could not connect server

Travis CI Spring Boot Error (Gradle Error)

psql: could not connect to server... Is the server running on host ... and accepting TCP/IP connections on port 5432?

Key - Error when running in Travis CI| Pytest

Error authenticating Github using Travis CI

Travis-CI GoLang Examples test error

Travis-CI with: ERROR: Cannot find schemes

Travis CI R package error in documentation

Setting up PostGIS on Gitlab CI fails: psql could not connect to server: No such file or directory

Rails: rake db:create:all (could not connect to server) psql works fine

PHPUnit "Could not read phpunit.xml" on Travis CI

Postgres could not connect to server

Could not connect to development server on