By Cody Smith
As I was following through with the docker documentation for mautrix-facebook, I got to the point where I start the bot, it throws the error I’m going to put at the bottom of the message, I’m not sure what address to use or how to go about getting it to see the database or even if I’m going about the problem that it’s hanging on by trying to figure out what the right hostname to use. The error is this, it happens with both localhost and the domain name:
Traceback (most recent call last): File “/usr/lib/python3.9/site-packages/mautrix/util/program.py”, line 219, in _run self.loop.run_until_complete(self.start()) File “/usr/lib/python3.9/asyncio/base_events.py”, line 642, in run_until_complete return future.result() File “/usr/lib/python3.9/site-packages/mautrix_facebook/main.py”, line 99, in start await super().start() File “/usr/lib/python3.9/site-packages/mautrix/bridge/bridge.py”, line 174, in start await self.start_db() File “/usr/lib/python3.9/site-packages/mautrix/bridge/bridge.py”, line 163, in start_db await self.db.start() File “/usr/lib/python3.9/site-packages/mautrix/util/async_db/asyncpg.py”, line 44, in start self._pool = await asyncpg.create_pool(self.url, **self.db_args) File “/usr/lib/python3.9/site-packages/asyncpg/pool.py”, line 413, in async__init await self._initialize() File “/usr/lib/python3.9/site-packages/asyncpg/pool.py”, line 441, in _initialize await first_ch.connect() File “/usr/lib/python3.9/site-packages/asyncpg/pool.py”, line 133, in connect self._con = await self._pool._get_new_connection() File “/usr/lib/python3.9/site-packages/asyncpg/pool.py”, line 511, in _get_new_connection con = await connection.connect( File “/usr/lib/python3.9/site-packages/asyncpg/connection.py”, line 2085, in connect return await connect_utils._connect( File “/usr/lib/python3.9/site-packages/asyncpg/connect_utils.py”, line 895, in _connect raise last_error File “/usr/lib/python3.9/site-packages/asyncpg/connect_utils.py”, line 881, in _connect return await _connect_addr( File “/usr/lib/python3.9/site-packages/asyncpg/connect_utils.py”, line 781, in _connect_addr return await __connect_addr(params, timeout, True, *args) File “/usr/lib/python3.9/site-packages/asyncpg/connect_utils.py”, line 825, in __connect_addr tr, pr = await compat.wait_for(connector, timeout=timeout) File “/usr/lib/python3.9/site-packages/asyncpg/compat.py”, line 66, in wait_for return await asyncio.wait_for(fut, timeout) File “/usr/lib/python3.9/asyncio/tasks.py”, line 481, in wait_for return fut.result() File “/usr/lib/python3.9/site-packages/asyncpg/connect_utils.py”, line 691, in _create_ssl_connection tr, pr = await loop.create_connection( File “/usr/lib/python3.9/asyncio/base_events.py”, line 1017, in create_connection infos = await self._ensure_resolved( File “/usr/lib/python3.9/asyncio/base_events.py”, line 1396, in _ensure_resolved return await loop.getaddrinfo(host, port, family=family, type=type, File “/usr/lib/python3.9/asyncio/base_events.py”, line 856, in getaddrinfo return await self.run_in_executor( File “/usr/lib/python3.9/concurrent/futures/thread.py”, line 52, in run result = self.fn(*self.args, **self.kwargs) File “/usr/lib/python3.9/socket.py”, line 954, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name does not resolve
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
The error you’re encountering with the mautrix-facebook plugin for Matrix Synapse, specifically socket.gaierror: [Errno -2] Name does not resolve, suggests that the plugin is unable to resolve the hostname for the PostgreSQL database. This typically happens when the hostname provided in the database connection string is incorrect or not resolvable from the container where the plugin is running.
Here’s how you can troubleshoot and potentially resolve this issue:
Make sure that the database connection string you’ve provided to the mautrix plugin is correct. The connection string usually looks like postgresql://user:password@hostname/database. If you’re using Docker, localhost won’t work because the plugin and the database aren’t in the same network namespace. Instead, you should use the Docker service name defined in your docker-compose.yml or the IP address of the PostgreSQL server.
If both your mautrix plugin and PostgreSQL database are running in Docker, make sure they are on the same Docker network. This way, you can use the service name defined in docker-compose.yml as the hostname.
Example docker-compose.yml snippet:
services:
db:
image: postgres
networks:
- mautrix-net
mautrix:
image: mautrix-facebook
networks:
- mautrix-net
environment:
- DATABASE=postgresql://user:password@db/database
networks:
mautrix-net:
driver: bridge
In the example above, the mautrix service can connect to PostgreSQL using db as the hostname.
If you’re not using Docker networking, you can find out the IP address of the PostgreSQL server and use that in your connection string. If PostgreSQL is running on the same host but outside Docker, you might be able to use the host’s internal IP address (often 172.17.0.1 on Docker’s default bridge network) or the actual IP address of the host.
Make sure the PostgreSQL server is running and accessible. You can test connectivity from the mautrix plugin’s environment (or container) using tools like psql or telnet.
Example command to check connectivity:
psql -h hostname -U user -d database
Replace hostname, user, and database with your actual PostgreSQL server details.
On another note, make sure there are no firewall rules blocking the connection from the mautrix plugin to the PostgreSQL database.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.