Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5981107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:53:50+00:00 2026-05-22T21:53:50+00:00

There is a backend function in my site that will call urllib.urlopen(url)) to retrieve

  • 0

There is a backend function in my site that will call urllib.urlopen(url)) to retrieve data from url. After deploying, all other functions worked well except this one. Calling this function results in [Errno socket error] [Errno -2] Name or service not known. It seems that it can’t find the host.

But if I use python manage.py runserver to run the site, this function works well.

I’m wondering whether maybe there is some problem with Apache, but if there is I can’t find it. Thanks for your help.

This is the function:

WORD_URL = 'http://dict.cn/ws.php?utf8=true&q=%s'

def get_word(word):
    url = WORD_URL % word
    dom = minidom.parse(urllib.urlopen(url))
    try:
        pron = dom.getElementsByTagName('pron')[0].firstChild.data
        definition = dom.getElementsByTagName('def')[0].firstChild.data
    except IndexError:
        pron = ''
        definition = ''
    return {
        'word':word,
        'pron':pron,
        'definition':definition
        }

This is the traceback:

Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/jxq/djcode/wormo/core/views.py" in added
31.             xml_word = get_word(new_word)
File "/home/jxq/djcode/wormo/core/get_word.py" in get_word
8.     dom = minidom.parse(urllib.urlopen(url))
File "/usr/lib/python2.7/urllib.py" in urlopen
84.         return opener.open(url)
File "/usr/lib/python2.7/urllib.py" in open
205.                 return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py" in open_http
342.         h.endheaders(data)
File "/usr/lib/python2.7/httplib.py" in endheaders
937.         self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py" in _send_output
797.         self.send(msg)
File "/usr/lib/python2.7/httplib.py" in send
759.                 self.connect()
File "/usr/lib/python2.7/httplib.py" in connect
740.                                              self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py" in create_connection
553.     for res in getaddrinfo(host, port, 0, SOCK_STREAM):

Exception Type: IOError at /wormo/added/
Exception Value: [Errno socket error] [Errno -2] Name or service not known

httpd.conf:

WSGIScriptAlias / /home/jxq/djcode/wormo/apache/django.wsgi

<Directory /home/jxq/djcode/wormo/apache>
    Order allow,deny
    Allow from all
</Directory>

Alias /media/ /home/jxq/djcode/wormo/media/

<Directory /home/jxq/djcode/wormo>
Order deny,allow
Allow from all
</Directory>

Python 3 and Python 2.7 are both on my machine. Is this a problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:53:51+00:00Added an answer on May 22, 2026 at 9:53 pm

    It’s possible that this could be a permission issue or something else with your Apache environment. Try using a simple WSGI script as a baseline to test URL fetching:

    import sys
    import urllib    
    
    def application(environ, start_response):
       page_text = urllib.urlopen("http://www.google.com/").read()
       start_response('200 OK', [
         ('Content-Type', 'text/html'),
         ('Content-Length', str(len(page_text))),
       ])
       yield page_text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi. I was trying to access backend URL from an AJAX call and here's
So I have a PHP backend that pulls some data from SQL, let's just
I have a website that needs to perform a certain backend function once per
There is an example of getting data from form using mapper in official quickstart
Okay, so I have an AJAX function that gets a JSON encoded string from
Hi im trying call this function from an element, but the element id is
I have a Flash app with a PHP backend. Whenever there is a PHP
The back-end admin interface informs me that there is a new security patch for
I have a three tier system, SQL Server backend, hand written data access layer,
There seem to be very different opinions about using transactions for reading from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.