I'm trying to get all events from contract, but get error: "ValueError: {'code': -32601, 'message': 'The method eth_newFilter does not exist/is not available'}"

I'm using Web3py and Infura. My code:

myfilter = <myContract>.events.<MyEvent>.createFilter(fromBlock=0)


myFilter = web3.eth.filter({"address": <myContractAddress>})

Why is this error? How do I get events? Help me please.

  • 1
    How are you connecting to Infura? eth_newFilter is only available via websocket. Commented Dec 4, 2019 at 12:12
  • Like this: from web3 import Web3 PROVIDER = 'https://ropsten.infura.io/v3/xxxxxxxxxxx' web3 = Web3(Web3.HTTPProvider(PROVIDER))
    – Alex
    Commented Dec 4, 2019 at 13:03
  • @iamdefinitelyahuman So I don't know why this error. As you can see in the code, I use Infura.
    – Alex
    Commented Dec 4, 2019 at 13:06

1 Answer 1


The issue is that Infura only exposes the eth_newFilter endpoint via websockets, but you are connecting via https.

Try using a WebsocketProvider when declaring your web3 instance, as shown in the following example:

from web3 import Web3

PROVIDER = "wss://ropsten.infura.io/ws/v3/YOUR-PROJECT-ID"
web3 = Web3(Web3.WebsocketProvider(PROVIDER))
  • Will all other methods work correctly? (via WebsocketProvider) And it will not affect speed of working with Infura?
    – Alex
    Commented Dec 4, 2019 at 15:30
  • 1
    Yes, per the infura docs all https endpoints will be available. And websockets is typically quicker. Commented Dec 4, 2019 at 15:42
  • Thank you! But I have other error
    – Alex
    Commented Dec 4, 2019 at 16:54
  • "websockets.exceptions.InvalidStatusCode: Status code not 101: 404"
    – Alex
    Commented Dec 4, 2019 at 16:56
  • 1
    ahh sorry, i made a mistake in the provider URL! I've updated my answer. Commented Dec 5, 2019 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.