PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 18, 2022

[FIXED] How to fix error when sending mail with django in docker container? (Cannot assign requested address)

 October 18, 2022     django, docker, python, smtp     No comments   

Issue

I'm getting an error when sending a letter both in Celery, as in the shell itself. Without the docker itself, there is no such error on the local computer, but there is on the server.

Error:

    send_mail('test', 'test msg', 'volkodav2312@bk.ru', ['volkodav2312@inbox.ru'])
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/__init__.py", line 87, in send_mail
    return mail.send()
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/message.py", line 298, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 124, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.10/site-packages/django/core/mail/backends/smtp.py", line 80, in open
    self.connection = self.connection_class(
  File "/usr/local/lib/python3.10/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.10/smtplib.py", line 341, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/local/lib/python3.10/smtplib.py", line 312, in _get_socket
    return socket.create_connection((host, port), timeout,
  File "/usr/local/lib/python3.10/socket.py", line 845, in create_connection
    raise err
  File "/usr/local/lib/python3.10/socket.py", line 833, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

I looked through the other answers and didn't find anything helpful. I have a password configured, this error occurs in the docker.


Solution

OSError: [Errno 99] Cannot assign requested address this means the provide ip/port is already taken.Change your ip/port and try again

find docker-compose.yml

version: '3.8'
services:
  web:
    build: .
    restart: unless-stopped
    ports: ['192.107.1.2:8000:8000'] # <-- change IP and port here
  

Try this



Answered By - Kiran S
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing