Results 1 to 3 of 3

Thread: Metasploit framework errors "could not connect to server"

  1. #1
    Join Date
    2014-Jun
    Posts
    22

    Metasploit framework errors "could not connect to server"

    Is there a way to fix this problem? Metasploit framework seems to start correctly but it would be nice to have it working completely as it should, and starting the service Postgresql doesnt open any listening ports as you will se further down

    Running Kali.2019.2a.arm on a Raspberry Pi 2B
    Nothing changed from ISO, except apt-get update / apt-get upgrade

    Below running Metasploit framework, that starts and works, but with some error (see picture)
    [i] Database already started
    [i] The database appears to be already configured, skipping initialization
    [-] ***rting the MetasplOit Framework console...|
    [-] * WARNING: No database support: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
    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?
    Trying to get the database to re-initiate..

    root@kali:~# msfdb reinit
    [i] Database already started
    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"?
    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"?
    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"?
    [+] Deleting configuration file /usr/share/metasploit-framework/config/database.yml
    [+] Stopping database
    [+] Starting database
    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"?
    [+] Creating database user 'msf'
    createuser: could not connect to database postgres: 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"?
    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"?
    [+] Creating databases 'msf'
    createdb: could not connect to database template1: 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"?
    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"?
    [+] Creating databases 'msf_test'
    createdb: could not connect to database template1: 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"?
    [+] Creating configuration file '/usr/share/metasploit-framework/config/database.yml'
    [+] Creating initial database schema
    rake aborted!
    PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
    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?
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/connection_handling.rb:87:in `connection'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.rb:941:in `initialize'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.rb:823:in `new'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.rb:823:in `up'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/migration.rb:801:in `migrate'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/tasks/database_tasks.rb:139:in `migrate'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
    /usr/share/metasploit-framework/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)

    Postgresql is started (se picture), but doesn't run properly and doesn't open the port 5432 to listen after a closer inspection

    root@kali:~# ss -ant
    State Recv-Q Send-Q Local Address:Port Peer Address:Port
    LISTEN 0 5 0.0.0.0:5901 0.0.0.0:*
    LISTEN 0 128 0.0.0.0:6001 0.0.0.0:*
    LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
    ESTAB 0 0 192.168.1.70:5901 192.168.1.163:50044
    LISTEN 0 128 [::]:22 [::]:*
    root@kali:~#
    root@kali:~# service postgresql status
    ● postgresql.service - PostgreSQL RDBMS
    Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor prese
    Active: active (exited) since Mon 2019-07-15 23:37:02 UTC; 19min ago
    Process: 497 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
    Main PID: 497 (code=exited, status=0/SUCCESS)

    Jul 15 23:37:02 kali systemd[1]: Starting PostgreSQL RDBMS...
    Jul 15 23:37:02 kali systemd[1]: Started PostgreSQL RDBMS.
    I even added it to update-rc.d

    update-rc.d postgresql enable
    didnt do any difference when booting up again

    problem2.jpg

    Any idea how to solve this

    (Also same seems to happens if i install armitage on top, It simply wont start a server for some reason)
    Last edited by webbsmurfen; 2019-07-16 at 00:14. Reason: filling in more info

  2. #2
    Join Date
    2015-Apr
    Location
    Rio de Janeiro
    Posts
    2
    Hi I'm having the same problem.

    That's what I get when run the command "systemctl status postgresql@11-main"

    [email protected] - PostgreSQL Cluster 11-main
    Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/[email protected]
    └─kali_postgresql.conf
    Active: failed (Result: protocol) since Tue 2019-10-01 20:34:35 -03; 1h 52min ago
    Process: 1905 ExecStartPre=/usr/share/kali-defaults/postgresql_reduce_shared_buffers 11/main (code=exited, status=0/SUCCESS)
    Process: 1907 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 11-main start (code=exited, status=1/FAILURE)

    Oct 01 20:34:34 kali systemd[1]: Starting PostgreSQL Cluster 11-main...
    Oct 01 20:34:35 kali postgresql@11-main[1907]: Error: /usr/lib/postgresql/11/bin/pg_ctl /usr/lib/postgresql/11/bin/pg_ctl start -D /var/lib/postgresql/11/main -l /var/log/postgresql/postgresql-11-main.log -s -o -c config_file="/etc/postgresql/11/main/postgresql.conf" exited with status 1:
    Oct 01 20:34:35 kali postgresql@11-main[1907]: 2019-10-01 23:34:35.180 UTC [1912] FATAL: could not load server certificate file "/etc/ssl/certs/ssl-cert-snakeoil.pem": No such file or directory
    Oct 01 20:34:35 kali postgresql@11-main[1907]: 2019-10-01 23:34:35.181 UTC [1912] LOG: database system is shut down
    Oct 01 20:34:35 kali postgresql@11-main[1907]: pg_ctl: could not start server
    Oct 01 20:34:35 kali postgresql@11-main[1907]: Examine the log output.
    Oct 01 20:34:35 kali systemd[1]: [email protected]: Can't open PID file /run/postgresql/11-main.pid (yet?) after start: No such file or directory
    Oct 01 20:34:35 kali systemd[1]: [email protected]: Failed with result 'protocol'.
    Oct 01 20:34:35 kali systemd[1]: Failed to start PostgreSQL Cluster 11-main.

  3. #3
    Join Date
    2015-Apr
    Location
    Rio de Janeiro
    Posts
    2
    Problem solved.
    All I had to do was re-generate the snakeoil certificates and it worked.
    I googled and found a solution at: https://gist.github.com/yyuu/4335041

    The solution used, in my case, was just the first 2 lines of the code below:
    sudo apt-get install ssl-certsudo
    make-ssl-cert generate-default-snakeoil
    sudo usermod --append --groups ssl-cert yyuu
    ls -l /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/private/ssl-cert-snakeoil.key
    Last edited by havilson; 2019-10-05 at 02:20.

Similar Threads

  1. metasploit-framework has no "external" folder
    By liangjs in forum Kali Linux TroubleShooting
    Replies: 0
    Last Post: 2023-06-08, 08:21
  2. Replies: 0
    Last Post: 2022-04-14, 02:30
  3. Replies: 0
    Last Post: 2020-11-13, 01:57
  4. cannot download "metasploit-framework" and "exploitdb" packages
    By fsasse in forum TroubleShooting Archive
    Replies: 4
    Last Post: 2016-08-01, 11:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •