Q: Assistance request for (psycopg2.DatabaseError) Connection timed out I am following the install instructions for the security utility opencve which imports data into a postgresql database:
https://docs.opencve.io/installation/manual/
I have followed all of the instructions including creating the 5G swap file. All tables create, no problems, however, the data import fails at this step:
opencve import-data

I receive the below errors referring to a timeout time and time again. Despite straw clutching which includes disabling the firewall, searching for any postgresql timeout parameters, creating a large swap file and attempting the install on another server, as well as verifying that psycopg2-binary is installed, I still hit the same problem in the same spot.
The full errors displayed are below but I believe the main part is:
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 725, in do_executem
cursor.executemany(statement, parameters)
psycopg2.DatabaseError: could not receive data from server: Connection timed out
If I look at that psycopg2.py file, this is the block of code with line 725 being the last line:
   def do_executemany(self, cursor, statement, parameters, context=None):
        if self.psycopg2_batch_mode:
            extras = self._psycopg2_extras()
            extras.execute_batch(cursor, statement, parameters)
        else:
            cursor.executemany(statement, parameters)

If this is a genuine timeout somewhere I can't see where. The connection is good as the tables get created in the earlier part of the import-data command.
This is the section that is repeatedly failing.
#####################
Importing CPE list...
#####################
[*] Downloading https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz... (done in 1.31s).
[*] Parsing XML elements... (done in 269.254s).
[*] Creating list of mappings... (done in 330.919s).
[*] Inserting Vendors and Products...Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1224, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 725, in do_executem
    cursor.executemany(statement, parameters)
psycopg2.DatabaseError: could not receive data from server: Connection timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opencve", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/opencve/commands/__init__.py", line 39, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask/cli.py", line 412, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/opencve/commands/imports/__init__.py", line 42, in import_data
    cpe.run(vendors)
  File "/usr/local/lib/python3.6/site-packages/opencve/commands/imports/cpe.py", line 63, in run
    db.session.bulk_insert_mappings(Vendor, mappings["vendors"].values())
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2790, in bulk_insert_mappings
    render_nulls,
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2880, in _bulk_save_mappings
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 129, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2874, in _bulk_save_mappings
    render_nulls,
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 102, in _bulk_insert
    bookkeeping=return_defaults,
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 1066, in _emit_insert_statements
    c = cached_connections[connection].execute(statement, multiparams)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
    distilled_params,
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1224, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 725, in do_executem
    cursor.executemany(statement, parameters)
sqlalchemy.exc.DatabaseError: (psycopg2.DatabaseError) could not receive data from server: Connection timed out

[SQL: INSERT INTO vendors (id, created_at, updated_at, name) VALUES (%(id)s, now(), now(), %(name)s)]
[parameters: ({'id': UUID('a53ecce1-d16d-4ae5-a20d-3c93034b8d32'), 'name': 'openbsd'}, {'id': UUID('98176222-30ad-498c5a-4a3981bc068e'), 'name': 'freebsd'}, {'id': UUID('f734d65f-f55d-4a3d-a099-189d120bfa99'), 'name': 'bsdi'}, {'id'UID('eadb7068-c668-4981-9190-5aba1ce58d6c'), 'name': 'redhat'}, {'id': UUID('ec37138d-9dc9-432f-a6a4-a4d2e80770b1'),ame': 'caldera'}, {'id': UUID('523ea159-56bc-48c6-914f-1ebecd0f1120'), 'name': 'tritreal'}, {'id': UUID('287ac9fb-654751-a005-625b43059719'), 'name': 'sun'}, {'id': UUID('167edc67-f559-42fb-a501-f91e4114faed'), 'name': 'hp'}  ... diaying 10 of 28136 total bound parameter sets ...  {'id': UUID('2121a912-76a3-453f-8963-09c537f4bf78'), 'name': 'zend_feedback_tab_project'}, {'id': UUID('5f742c4f-3e37-486d-b5aa-80a92e9f0559'), 'name': 'zyzel'})]
(Background on this error at: http://sqlalche.me/e/4xp6)

I have opened a case for comment on the opencve git page but there has been no response so, hoping that someone may have some advice here please.
