Networking⏱️ 2 min read📅 2026-06-03

How to Fix: SocketException: OS Error: Connection refused, errno = 111 in flutter using django backend

Connection refused error in Flutter Django backend

Quick Answer: Ensure the server is running and listening on the specified port, check firewall settings and verify the URL is correct.

The SocketException: OS Error: Connection refused, errno = 111 error in Flutter using Django backend occurs when the server is not listening on the specified port or the client is unable to establish a connection due to various reasons. Since you have removed CSRF protection and the request is being sent over HTTPS, here are some potential solutions:

🔧 Proven Troubleshooting Steps

Method 1: Check Server Configuration

  1. Step 1: Ensure that the Django server is configured to listen on the correct port. You can do this by modifying your `settings.py` file to include the following line: `REST_FRAMEWORK = {'DEFAULT_API_GROUP': 'api', 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.AllowAny']}`

Method 2: Verify Django Server is Running

  1. Step 1: Run the following command in your terminal to ensure the Django server is running: `python manage.py runserver`

Method 3: Check Network Connection

  1. Step 1: Verify that your network connection is stable and working correctly. You can do this by testing a different API endpoint in Postman or using a tool like `telnet` to establish a connection to the server.

🎯 Final Words

By following these steps, you should be able to resolve the SocketException: OS Error: Connection refused, errno = 111 error in your Flutter app using Django backend.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions