Running geth with websocket:

geth --fast --cache=512 --ws --wsorigins="*" --wsapi "db,eth,net,ssh,miner,web3,personal,admin"

Then connecting with web3 in a Node.js app:

const Web3 = require('web3');

var web3 = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546"));


web3.eth.subscribe('pendingTransactions', function(err, res) {
}).on('data', function(transaction) {
    console.log('Here 2')

"Here", "Here 2" do not print to the console. The subscription does not seem to activate. web3.version and other web3 commands work fine.

Geth version: 1.7.1-stable

Web3 version: 1.0.0-beta.22


2 Answers 2


Please make sure you are synced up. While geth is doing its fast sync, the chain is incomplete, so there aren't any events being fired, since there's no existing events yet. Only when the chain sync fully will events start appearing.


You are trying to get the pending transaction so event may not be fired, the event only get fired when transaction mined successful, in your case the chain will always be incomplete as you are only calling pending transaction

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.