Jump to content
We've recently updated our Privacy Statement, available here ×
  • Postgres backup command pg_dump failed on database connection


    vchiem
    • Version: v7, v6 Product: JasperReports® Server

    Issue:

    As per the command:

    pg_dump --username=postgres  jasperserver  >  js-db-dump.sql

    we received an error message:

    pg_dump: [archiver (db)] connection to database "jasperserver" failed: 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"?

     

    To get rid of this error, we tried the following command for backup:

    pg_dump jasperserver -U jasperdb -h localhost > js-db-dump-13FEB2020.sql

    but received:

    connection to database "jasperserver" failed: 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 5432?

    How to overcome these issues to successfully generate the dump file ?

     


     

    Solution:

    The error represents a connection problem to the postgres database. 

    So it is essential to firstly know whether the postgres is running and on what port number (default port is 5432). 

    Once you know this information, you can use this to force the connection with extra parameters passed with the pg_dump command :

    -h host 

    -p port

    -U username

    -W

    You can refer to the following page for reference:

    https://www.postgresql.org/docs/9.3/app-pgdump.html

    If it is still an issue and the error that you are getting remains exactly the same then probably there is an incorrect path to socket. 

    Backup tried to connect to /var/run/postgresql/.s.PGSQL.5432 but it does not exist. Hence you can check this article:

    https://stackoverflow.com/questions/31645550/why-psql-cant-connect-to-server

    to check for the location of the socket file and verify the configuration files, pg_hba.conf and postgresql.conf are correctly set.

    There are mentions to check for unix_socket_directories parameter setting and set it to /tmp

    It is recommended to check that this parameter is in place as well:

    listen_addresses = '*'


    User Feedback

    Recommended Comments

    if you want to get dump of jasperserver db from postgresql.

    you should be stop the process of tomcat.

    '''

    $ ctllscript.sh stop tomcat

    '''

    Then you will use pg_dump command from under the jaspersoft application directory.

    '''

    $ $JASPER_DIR/postgresql/bin/pg_dump -U User jasperserver > dump_filename.dump

    '''

    It may not be possible to retrieve the data due to the difference between the server and client versions.

     

    Please try it!

     

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...