question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

urllib3.exceptions.LocationValueError: No host specified.

See original GitHub issue

Hi there.

First of all many thanks to all people involved in this project.

I’m facing an issue with version 1.25.2 of this library, which is not happening with version 1.24.1.

Steps to reproduce:

  1. Create “requirements.txt” with below content:
selenium
urllib3==1.24.1
#urllib3==1.25.2
  1. Create “Dockerfile” with below content:
FROM python:3-stretch

ADD requirements.txt .

RUN pip install -r requirements.txt

COPY test.py /test.py
  1. Create “test.py” with below content:
#!/usr/bin/python

from selenium import webdriver

host = 'selenium'
port = '4444'
url = host + ':' + port + '/wd/hub'

desired_capabilities = {
    'browserName': 'firefox',
    'javascriptEnabled': True,
}

driver = webdriver.Remote(command_executor = url, desired_capabilities =
                                                          desired_capabilities)
print('Success')
driver.quit()
  1. Create “docker-compose.yaml” with below content:

services:

 urllib3:
  container_name: urllib3
  build:
   context: .
  stdin_open: true
  tty: true

 selenium:
  container_name: selenium
  image: selenium/standalone-firefox
  # Mandatory, to avoid "Message: Failed to decode response from marionette" error
  shm_size: 128m
  1. Bring up the environment
docker-compose up -d --build
  1. Test it:
docker exec -ti urllib3 python /test.py

Expected output:

Success
  1. Now edit “requirements.txt”
vim requirements.txt

And specify version 1.25.2 of urllib3:

selenium
#urllib3==1.24.1
urllib3==1.25.2
  1. Bring down the environment
docker-compose down
  1. Bring up the environment
docker-compose up -d --build
  1. Test it:
docker exec -ti urllib3 python /test.py

Expected output:

Traceback (most recent call last):
  File "test.py", line 15, in <module>
    desired_capabilities)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 402, in _request
    resp = http.request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 72, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 150, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 315, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
  File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 222, in connection_from_host
    raise LocationValueError("No host specified.")
urllib3.exceptions.LocationValueError: No host specified.
  1. (Optional) Cleanup
docker-compose down
docker rmi localhost/urllib3:latest

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sethmlarsoncommented, May 18, 2019

(Also I suspect you can fix your issue by adding http:// to the beginning of your URL)

0reactions
AndreiPy13commented, Jan 18, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Error:No host specified - Stack Overflow
I just wrote a simple python demo,while met a confusing problem. import requests print(requests.get('http://www.sina.com.cn/ ...
Read more >
Urllib3 Python3, Getting Error No host specified, but the url ...
I am trying to write images to database from excel sheet. I have this function to download images. def downloadImage(url, Name): try: http ......
Read more >
Exceptions - urllib3 1.26.13 documentation
Raised when get_host or similar fails to parse the URL input. exception urllib3.exceptions.LocationValueError#. Bases: ValueError ...
Read more >
connectionpool.py - Google Git
from .exceptions import ( ... raise LocationValueError("No host specified.") ... Additional parameters are used to create fresh :class:`urllib3.connection.
Read more >
urllib3 [python2-library] - Occam :: Details
urllib3 is a powerful, user-friendly HTTP client for Python. ... Requesting an empty host will raise urllib3.exceptions.LocationValueError . (Issue #417).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found