<p>Sometimes this error is thrown because passing too many characters as rpcuser or rpcpassword in the config file I have sorted out this issue with reducing the length of the rpcuser and password and removing special characters </p>

CC BY-SA 3.0
2014-03-15T02:00:11.723Z
2014-03-15T02:00:11.723Z
Khan Shahrukh
<p>First add this line to <code>litecoin.conf</code></p>

<pre><code>rpcallowip=127.0.0.1
</code></pre>

<p>Then make sure you've added the litecoin command to your path</p>

<pre><code>sudo cp litecoind /usr/bin/litecoind
</code></pre>

<p>and that your starting the litecoin daemon</p>

<pre><code>litecoind -daemon
</code></pre>

<p>and test with </p>

<pre><code>litecoind getinfo
</code></pre>

<p>if all that works then JSON RPC should work fine. </p>

<p>If none of that works try setting up the client by following this <a href="https://litecointalk.org/index.php?topic=43.0" rel="nofollow">guide</a>.</p>

<p>Also make sure your <code>username</code> and <code>password</code> are consistent across your PHP and <code>litecoin.conf</code> because they aren't in your example. </p>

CC BY-SA 3.0
2014-01-13T11:20:19.927Z
I have figured out that error_reporting was turned off in my php.ini file that is why it wasn't showing any error, now that I turned them on running litecoin.php on my server shows following error:
Khan Shahrukh
CC BY-SA 3.0
2014-01-13T01:47:53.093Z
2014-01-13T01:53:39.460Z
2014-01-13T01:53:39.460Z
Loourr
<p>Just before few hour I have setup bitcoin daemon on my ubuntu server and tested it with API and it is responding very well. Now I have installed litecoin daemon on the same server and used copied the same php files with a little sytax changes like change in username and password and port number but it is not responding to any API calls. </p>

<p>Content of litecoin.conf are :</p>

<pre><code>server=1
daemon=1
rpcuser=my_username
rpcpassword=mypassword
rpcport=9332
</code></pre>

<p>Content of litecoin.php</p>

<pre><code>&lt;?php
include_once('jsonRPCClient.php');
$variable = $_GET['variable'];
$litecoin = new jsonRPCClient('http://my_user:my_password@127.0.0.1:9332/');
if($variable=='getnewaddress')
{
echo $litecoin-&gt;getnewaddress();
}
else if($variable=='getinfo')
{
print_r($litecoin-&gt;getinfo());
}
else
{
echo "hello";
}
?&gt;
</code></pre>

<p>Any help of what I am doing wrong here ?</p>

<p>I was trying to figure out why php file is not throwing any error if there is any then I discovered that error_reporting in php.ini file is turned off after turning it on I got following error while executing litecoin.php on the browser :</p>

<p>Warning: fopen(<a href="http://...@myserveraddress.com:9332/" rel="nofollow">http://...@myserveraddress.com:9332/</a>): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /var/www/jsonRPCClient.php on line 132</p>

<p>Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to <a href="http://myuser:mypassword@myserveraddress.com:9332/" rel="nofollow">http://myuser:mypassword@myserveraddress.com:9332/</a>' in /var/www/jsonRPCClient.php:140 Stack trace: #0 /var/www/litecoin.php(12): jsonRPCClient->__call('getinfo', Array) #1 /var/www/litecoin.php(12): jsonRPCClient->getinfo() #2 {main} thrown in /var/www/jsonRPCClient.php on line 140</p>

CC BY-SA 3.0
2014-01-12T22:15:44.517Z
You are using HTTP, so you can use an IP packet sniffer to see what's going on. Is your connection accepted by the server? Does the server respond with any kind of HTTP response?
Greg Hewgill
CC BY-SA 3.0
2014-01-12T22:23:08.627Z
@GregHewgill I have used the same file with bitcoin daemon with different parameters and its working fine. But litecoin is not working
Khan Shahrukh
CC BY-SA 3.0
2014-01-12T23:59:22.710Z
Yes, you already said it wasn't working, but you haven't given any information that would allow anybody to guess a reason. I am suggesting a method for you to do some diagnostics to find out *why* it is not working.
Greg Hewgill
<litecoin><php><daemon>
Litecoin daemon is not responding to API calls
Khan Shahrukh
# Litecoin daemon is not responding to API calls

(Asked by: username_0 on 2014-01-12)

Just before few hour I have setup bitcoin daemon on my ubuntu server and tested it with API and it is responding very well. Now I have installed litecoin daemon on the same server and used copied the same php files with a little sytax changes like change in username and password and port number but it is not responding to any API calls.

Content of litecoin.conf are :

```
server=1
daemon=1
rpcuser=my_username
rpcpassword=mypassword
rpcport=9332

```

Content of litecoin.php

```
<?php
include_once('jsonRPCClient.php');
$variable = $_GET['variable'];
$litecoin = new jsonRPCClient('http://my_user:my_password@127.0.0.1:9332/');
if($variable=='getnewaddress')
{
echo $litecoin->getnewaddress();
}
else if($variable=='getinfo')
{
print_r($litecoin->getinfo());
}
else
{
echo "hello";
}
?>

```

Any help of what I am doing wrong here ?

I was trying to figure out why php file is not throwing any error if there is any then I discovered that error\_reporting in php.ini file is turned off after turning it on I got following error while executing litecoin.php on the browser :

Warning: fopen(<http://...@myserveraddress.com:9332/>): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /var/www/jsonRPCClient.php on line 132

Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to <http://myuser:mypassword@myserveraddress.com:9332/>' in /var/www/jsonRPCClient.php:140 Stack trace: #0 /var/www/litecoin.php(12): jsonRPCClient->\_\_call('getinfo', Array) #1 /var/www/litecoin.php(12): jsonRPCClient->getinfo() #2 {main} thrown in /var/www/jsonRPCClient.php on line 140

**Tags:** litecoin, php, daemon

> **Comments:**
> **username_1**: You are using HTTP, so you can use an IP packet sniffer to see what's going on. Is your connection accepted by the server? Does the server respond with any kind of HTTP response?  
> **username_0**: @username_1 I have used the same file with bitcoin daemon with different parameters and its working fine. But litecoin is not working  
> **username_1**: Yes, you already said it wasn't working, but you haven't given any information that would allow anybody to guess a reason. I am suggesting a method for you to do some diagnostics to find out *why* it is not working.  

---

## 2 answers

### Answer by username_0 on 2014-03-15. Score: 0 | Accepted answer

Sometimes this error is thrown because passing too many characters as rpcuser or rpcpassword in the config file I have sorted out this issue with reducing the length of the rpcuser and password and removing special characters


---

### Answer by username_2 on 2014-01-13. Score: 1

First add this line to `litecoin.conf`

```
rpcallowip=127.0.0.1

```

Then make sure you've added the litecoin command to your path

```
sudo cp litecoind /usr/bin/litecoind

```

and that your starting the litecoin daemon

```
litecoind -daemon

```

and test with

```
litecoind getinfo

```

if all that works then JSON RPC should work fine.

If none of that works try setting up the client by following this [guide](https://litecointalk.org/index.php?topic=43.0).

Also make sure your `username` and `password` are consistent across your PHP and `litecoin.conf` because they aren't in your example.

> **Comments:**
> **username_0**: I have figured out that error_reporting was turned off in my php.ini file that is why it wasn't showing any error, now that I turned them on running litecoin.php on my server shows following error:  

---

