How to enable PostgreSQL in a rails app with termux

433 Views Asked by At

I'm trying create a app with ruby on rails in termux, I already installed the necessary gems and packages for the setup, but when doing rails db:create. I get this error

rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Caused by:
PG::ConnectionBad: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
1

There are 1 best solutions below

0
Ravener On

You need to start a PostgreSQL server manually for your app to be able to connect to.

Install postgresql via pkg install postgresql

See the wiki for sample setup instructions https://wiki.termux.com/wiki/Postgresql