API Gateway and postgresql logging not working for local development
Problem
Bug report `API Gateway` and `postgresql` logging not working for local development. It is very frustrating that the supabase team is not working to improve the local development experience. I even updated the supabase. Deleted the complete docker images plus volumes and restarted the local environment. Still, it does not work. Also before that, I tried `supabase db reset` it also didn't work. Expected behavior One should not get a 502 error. Screenshots <img width="1440" alt="Screenshot 2024-05-27 at 5 08 14 AM" src="https://github.com/supabase/supabase/assets/21134455/4a6deeb9-45e5-4fc7-8e4a-65e290ec4369"> <img width="1440" alt="Screenshot 2024-05-27 at 5 08 28 AM" src="https://github.com/supabase/supabase/assets/21134455/4567c831-c5f8-4ef4-a036-204593dfc06b"> My config.toml file [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix API Gateway and PostgreSQL Logging for Local Development
The issue arises due to misconfiguration in the local environment setup, particularly with Docker containers not properly linking the API Gateway and PostgreSQL services, leading to a 502 error. This can occur if the services are not correctly defined in the Docker Compose file or if the logs are not being directed to the correct output streams.
Awaiting Verification
Be the first to verify this fix
- 1
Check Docker Compose Configuration
Ensure that the Docker Compose file correctly defines the services for API Gateway and PostgreSQL. Verify that the API Gateway service is dependent on the PostgreSQL service.
yamlversion: '3' services: api: image: supabase/api depends_on: - db db: image: supabase/postgres environment: POSTGRES_PASSWORD: 'your_password' - 2
Verify Environment Variables
Check that the necessary environment variables for both the API Gateway and PostgreSQL are set correctly. This includes database connection strings and logging configurations.
bashexport SUPABASE_DB_URL='postgres://user:password@db:5432/dbname' export SUPABASE_LOG_LEVEL='debug' - 3
Rebuild Docker Containers
After verifying the configuration, rebuild the Docker containers to ensure changes take effect. This can resolve issues related to stale configurations.
bashdocker-compose down docker-compose up --build - 4
Check Logs for Errors
After starting the services, check the logs for both the API Gateway and PostgreSQL to identify any errors or warnings that might indicate further issues.
bashdocker-compose logs api docker-compose logs db - 5
Test API Endpoints
Once the services are running, test the API endpoints to ensure they are responding correctly and that logging is functioning as expected. Use tools like Postman or curl.
bashcurl http://localhost:3000/api/v1/your-endpoint
Validation
Confirm that the API Gateway is returning the expected responses without 502 errors and that logs are being generated for both the API Gateway and PostgreSQL services. Check the console output and log files for any entries indicating successful operations.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep