The firewalls on VPS are off by default when it is built. So it is only active if you enable it. Since you're running the database inside Docker instead of directly on the VPS you have to allow the remote connection twice. Once it get outside the Docker container, and then again to get outside the VPS. If you install PostgreSQL directly it's a little easier and you only have to allow it once instead of having two layers. This link should help you https://stackoverflow.com/a/37704532 If after reading this stackoverflow you still have questions, let us know.