Skip to content

Fix frontend login ERR_CONNECTION_REFUSED by exposing backend on port 8000 #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

Itz-Agasta
Copy link
Contributor

This PR resolves the issue where login submissions from the nextjs frontend returned an ERR_CONNECTION_REFUSED error. The root cause was that the frontend was configured to send authentication requests to http://localhost:8000, but the backend (Django via Nginx) was only exposed on port 80 in Docker Compose.

Changes made:

  • Updated docker-compose.yaml to expose Nginx on port 8000 ("8000:80"), allowing frontend requests to localhost:8000 to be routed correctly to the backend.
  • No changes to frontend code, as the base URL in constants.ts already points to http://localhost:8000.

How to test:

  1.  docker compose up -d
  2. create a super user
docker-compose exec buffalogs python manage.py shell -c "
from authentication.models import User
user = User.objects.create_superuser(username='admin', email='[email protected]', password='admin123')
print(f'Superuser created: {user.username}')
"
  1. Browse to http://localhost:3000.
  2. Submit login credentials; authentication should now work without connection errors.

Closes #292

@Itz-Agasta
Copy link
Contributor Author

Itz-Agasta commented Aug 5, 2025

Hi @Lorygold, while working on the main issue (#292), I discovered another related bug. When starting the application with docker-compose up, the main Django application containers exit immediately with the error "uwsgi: command not found". This prevents the backend API from functioning, making the application unusable.

Reproduction Steps

  1. Start Docker Compose services:

    docker-compose up -d
  2. Check container status:

    docker-compose ps -a
  3. Observe the issue:

    • Main Django containers (buffalogs, buffalogs_celery, buffalogs_celery_beat) show as Exited
    • Only buffalogs_postgres, buffalogs_rabbitmq, buffalogs_frontend, buffalogs_nginx are running
Screenshot_05-Aug_18-17-29_3656
  1. Check logs to confirm error:
    docker-compose logs buffalogs

Error in logs:

buffalogs  | ./run.sh: line 13: uwsgi: command not found
Screenshot_05-Aug_18-18-07_27262

The issue occurs because:

  1. The run.sh script tries to execute uwsgi --ini buffalogs_uwsgi.ini
  2. uWSGI is not installed in the Docker container
  3. The requirements.txt file is missing the uWSGI dependency
  4. This causes the container to exit immediately with error code 127 (command not found)

This why i add the missing uWSGI dependency to the requirements file.

@Lorygold
Copy link
Collaborator

Lorygold commented Aug 5, 2025

@Itz-Agasta nice catch regarding the containers bug!
and I really appreciate your detailed analysis and comments, very good job, thanks

@Lorygold Lorygold self-requested a review August 5, 2025 16:05
@Lorygold Lorygold merged commit a67ad15 into certego:develop Aug 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] frontend: ERR_CONNECTION_REFUSED for NodeJS frontend superuser login
2 participants