hop-along-polly / always-on

AlwaysON is the REST API that always responds with the EXACT response you want.
GNU General Public License v3.0
0 stars 0 forks source link

[Bug] AlwaysON API cannot connect to MongoDB in Docker 🤷 #4

Closed hop-along-polly closed 2 months ago

hop-along-polly commented 2 months ago

Context

AlwaysON sets up a standard development environment with Docker Compose. This means the API should be able to talk with the MongoDB container.

Problem Statement

When starting the application with docker-compose up the API is unable to connect with MongoDB and times out on any POST requests to the /manifests endpoint with the following error.

Error occurred during an upsert "always-on"     # needs to match username in build:27017: [Errno -2] Name or service not known (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 663d31ea6c89d7d362eb1f34, topology_type: Unknown, servers: [<ServerDescription ('"always-on"     # needs to match username in build', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('"always-on"     # needs to match username in build:27017: [Errno -2] Name or service not known (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]>
hop-along-polly commented 2 months ago

Turns out this was a weird environment variable issue. Despite resetting the .env file, hard-coding values in docker-compose, rebuilding images and docker volumes some old environment variables remained on the system. Restarting my laptop fixed this issue. Computers are weird 🤷‍♂️